Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cefSharp wpf Keyboard input do not appear in the browser. #362

Closed
JPipe opened this issue May 20, 2014 · 39 comments
Closed

cefSharp wpf Keyboard input do not appear in the browser. #362

JPipe opened this issue May 20, 2014 · 39 comments
Labels
bug cef3 wpf WPF Implementation

Comments

@JPipe
Copy link

JPipe commented May 20, 2014

I have a winform app hosting a wpf form in which the cef browser is added (don't ask this is a legacy product...) .
I am able to navigate, evaluate script, but cannot get the the keyboard input to appear in the browser.
Running in the debugger, I can see the keystrokesprocessed by the CefSharp.wpf WebView event (OnPreviewKey & SourceHook), but never seem to make it to the browser UI.
Other keys such as tabs & arrow keys navigate fine in the browser but no characters seems to make it into the UI.

It's almost as if the key is being processed correctly, but is sent to the wrong destination.

Can anyone help?

Thanks,

Jan

@jornh
Copy link
Contributor

jornh commented May 20, 2014

(don't ask this is a legacy product...) .

No questions asked 😄

Which CefSharp version do you see this with?
Could you easily make some minimal-ish example to reproduce?

@JPipe
Copy link
Author

JPipe commented May 21, 2014

Version 3.29.0.0 - I just finished the minimal example - how do I send?

@JPipe
Copy link
Author

JPipe commented May 21, 2014

Also reproducible with 3.1650

@jornh
Copy link
Contributor

jornh commented May 21, 2014

Also reproducible with 3.1650

Do you mean on a source build from HEAD of our master branch - or using the 31.0.0-pre1 Wpf Nuget?

... OK, so I guess we either have a bug which can affect general Wpf use - or maybe a bug introduced by the WinForms wrapping - the way you have done it - or in general. It is something we currently don't have an example of doing in the project. But - as your case illustrates - is a valid case for some people, hence my interest in it (apart from that we want to help you succeed :-)

I just finished the minimal example - how do I send?

Preferably put your sources up here on GitHub or alternatively I guess you could dump it into a zip and post it e.g. in the CefSharp Google group.

@JPipe
Copy link
Author

JPipe commented May 21, 2014

Thanks - I'd like to succeed too!

I just downloaded the code from CefSharp-master.
Since I'm not sure how to put the source on GitHub, I just posted on the group https://groups.google.com/forum/#!topic/cefsharp/cer-4O6igLg

@jornh
Copy link
Contributor

jornh commented May 21, 2014

Sorry @JPipe I'm out of steam for today ... will have a look within the next few days though.

@amaitland if you have got the time/interest in this you're welcome to take a peek.

@JPipe
Copy link
Author

JPipe commented May 21, 2014

I understand, and thanks for keeping me posted - sounds like a post memorial day thing :-)

@amaitland
Copy link
Member

@JPipe Thanks for the example, looking at this now

@amaitland
Copy link
Member

I'm able to reproduce the issue, it looks isolated to Wrapping the WPF control in a WinForms host.
The SourceHook fires as expected, makes the appropriate managedCefBrowserAdapter.SendKeyEvent call, just nothing happens. So this one will require some further investigation.

@JPipe
Copy link
Author

JPipe commented May 22, 2014

Thanks - I appreciate. I'm still looking at it myself.

@amaitland
Copy link
Member

For reference I've taken the example you provided, made a few changes and made it available here https://github.com/amaitland/CefSharp/tree/bug/wpf-hosted-in-winforms

In the short term are you able to open your WPF Window as a modal Dialog? That should get around the issue. First though is that it'll be something to do with the message loop being shared between WinForms and WPF. MSDN - Sharing Message Loops Between Win32 and WPF

Example of ShowDialog call https://github.com/amaitland/CefSharp/blob/bug/wpf-hosted-in-winforms/WPFHostedInWinForm/WinFormsExampleHost.cs#L15

@jornh jornh added the bug label May 22, 2014
@JPipe
Copy link
Author

JPipe commented May 22, 2014

Thanks @amaitland I'm trying it out...The app is a bit of a monster, and I'm not sure if going model will have some downstream impact.

@JPipe
Copy link
Author

JPipe commented May 22, 2014

Hi,

I'm making some progress, but now when I try to EvaluateScript
I get the following exception:
"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."

To get the browser content, I use EvaluateScript(@"document.documentElement.outerHTML"); that worked OK (no longer does) and since I'm not knowingly binding to anything, I just don't know were to increase the MaxReceivedMessageSize property.

any idea how to get passed this one, or even better is there a method that will give me the page content.

@JanEggers
Copy link
Contributor

@perlun it seems we have to boost the binding parameters a bit / should we provide the user of cefsharp some kind of api to configure the binding themselves ?

@JPipe cef 3 uses wcf to communicate with a subprocess that isolates the browser that wasnt in place with cef 1.0. and that wcf communication has some limits if used in default config. the dom of your page seems to use more than 64KB

@JPipe
Copy link
Author

JPipe commented May 22, 2014

Thanks - an API would be nice. What shall I do in the mean time?
Any way I can boost the binding property myself?

@perlun
Copy link
Member

perlun commented May 22, 2014

An API for this seems overkill to me. Let's change the fixed limit to 16 megabytes or something like that instead.

Sent from my iPhone

On 22 maj 2014, at 23:30, "JanEggers" <[email protected]mailto:[email protected]> wrote:

@perlunhttps://github.com/perlun it seems we have to boost the binding parameters a bit / should we provide the user of cefsharp some kind of api to configure the binding themselves ?

@JPipehttps://github.com/JPipe cef 3 uses wcf to communicate with a subprocess that isolates the browser that wasnt in place with cef 1.0. and that wcf communication has some limits if used in default config. the dom of your page seems to use more than 64KB

Reply to this email directly or view it on GitHubhttps://github.com//issues/362#issuecomment-43940090.

@JPipe
Copy link
Author

JPipe commented May 22, 2014

Works for me - Let me know when available)

@JPipe
Copy link
Author

JPipe commented May 27, 2014

Just to keep the ball rolling (so I can continue with the cefSharp integration) - is there any timeline for both issue resolution (WinForm Hosting WPF lost keystrokes & EvaluateScript)?

Thanks,

Jan

@amaitland
Copy link
Member

@JPipe When calling EvaluateScript Is it purely the source you're after? I believe the intention was to add a GetSource() method in the short term, would that be beneficial?

@JPipe
Copy link
Author

JPipe commented May 28, 2014

Yes - that will work in the short term, but I will also have to support JS and the possibility of having large JS return object still exist...

PS: can you clarify short Term.

Thanks,

Jan

@amaitland
Copy link
Member

The basic plumbing for GetSource() is relatively straight forward, I've got the basics implemented here amaitland@8879e41. I'm still pondering how best to expose that in the WebView class, the call is actually executed in an async fashion, so ideally we wrap that in a nice way.

As for changing MaxReceivedMessageSize I haven't had a chance to test it as yet, though the change will look something like this amaitland@85ef366

Both changes are on my WIP branch and aren't ready for prime time just yet (there are also a large number of other changes on that branch, mostly just code cleanup and restructuring stuff). If your game, you could checkout that branch and build it locally.

@perlun
Copy link
Member

perlun commented May 28, 2014

It sounds like GetSource should return a Task then, I guess.

Sent from my iPhone

On 28 maj 2014, at 06:28, "amaitland" <[email protected]mailto:[email protected]> wrote:

The basic plumbing for GetSource() is relatively straight forward, I've got the basics implemented here amaitland/CefSharp@8879e41amaitland@8879e41. I'm still pondering how best to expose that in the WebView class, the call is actually executed in an async fashion, so ideally we wrap that in a nice way.

As for changing MaxReceivedMessageSize I haven't had a chance to test it as yet, though the change will look something like this amaitland/CefSharp@85ef366amaitland@85ef366

Both changes are on my WIP branch and aren't ready for prime time just yet (there are also a large number of other changes on that branch, mostly just code cleanup and restructuring stuff). If your game, you could checkout that branch and build it locally.

Reply to this email directly or view it on GitHubhttps://github.com//issues/362#issuecomment-44362051.

@amaitland
Copy link
Member

@perlun returning Task<string> does sound like the way to go. Here is the basic idea of what I was thinking amaitland@aedc0d9, it uses TaskCompletionSource<string> to notify the task when the IStringVisitor.Visit has been called.

Thoughts?

@JPipe
Copy link
Author

JPipe commented May 28, 2014

I have to say that from a user point of view, getting the string back with one call requiring no callback is more appealing.

@JPipe
Copy link
Author

JPipe commented May 28, 2014

@amaitland - Thanks I increased the MaxReceivedMessageSize binding but kept the ChannelFactory rather than moving to the duplex model (keeping the changes to a minimum for now) since it looks like some serious re-factoring is taken place... and it works!

@amaitland
Copy link
Member

@JPipe Thanks for the feedback, once the technical implementation is ironed out, it's only a couple of lines to implement a synchronous implementation of GetSource() so that's a no brainier. Will add that to the IWebBrowser interface shortly.

If you have a min set of changes that resolves MaxReceivedMessageSize perhaps you could generate a Pull Request and I can see about getting it merged? TIA!

@JPipe
Copy link
Author

JPipe commented May 28, 2014

@amaitland - any instructions on how to generate a pull request?

@amaitland
Copy link
Member

Basic steps are something like this

  • Fork CefSharp (View the CefSharp repository on GitHub, there is a button top right "Fork")
  • Clone a local copy of your fork using a Git client (URL will look something like https://github.com/JPipe/CefSharp.git) or if you have GitHub Windows client, then just click the "Clone in Desktop" button on your CefSharp fork
  • Commit changes to your local copy
  • When your happy, push your local changes to your fork
  • Visit your GitHub webpage (https://github.com/JPipe/CefSharp), it will prompt you to create a pull request containing the changes you just made.

It's also worth having a quick read over https://github.com/cefsharp/CefSharp/blob/master/CONTRIBUTING.md to get a sense of coding style, biggest one to note is spaces instead of tabs also for C++ which is not the default VStudio setting when starting out.

Reference articles that maybe of help

Git Clients worth considering

The GitHub windows client is probably the simplest interface, I started using it, though quickly moved away once I got more comfortable with Git. Their website has reasonable help, and it tightly integrates with GitHub of course.

Let me know how you go or if you require more info.

@amaitland
Copy link
Member

@JPipe Was that info helpful? I was thinking it might be worth creating a wiki item for future reference.

@JPipe
Copy link
Author

JPipe commented May 29, 2014

@amaitland That's not a bad idea, though I am still trying to work my way
through it (along with the stream of meetings I've had the past couple
days) - I think I forked from your branch, rather than the main and haven't
been able to fix that. Today is mostly already shot so I'll resume tomorrow.

On Thu, May 29, 2014 at 3:04 PM, amaitland [email protected] wrote:

@JPipe https://github.com/JPipe Was that info helpful? I was thinking
it might be worth creating a wiki item for future reference.


Reply to this email directly or view it on GitHub
#362 (comment).

Jan Piper

@amaitland
Copy link
Member

If you go to https://github.com/JPipe/CefSharp, click on "Settings" on the right hand side, scroll down that page and you should see the option to delete the repository. Once you've done that, you can fork the main CefSharp repository 😄

If you have any suggestions for the wiki page any contribution would be greatly appreciated!

@JPipe
Copy link
Author

JPipe commented Jun 2, 2014

@amaitland - I just committed the changes for the max object size net pipe
binding
.

On Thu, May 29, 2014 at 4:06 PM, amaitland [email protected] wrote:

If you go to https://github.com/JPipe/CefSharp, click on "Settings" on
the right hand side, scroll down that page and you should see the option to
delete the repository. Once you've done that, you can fork the main
CefSharp repository [image: 😄]

If you have any suggestions for the wiki page any contribution would be
greatly appreciated!


Reply to this email directly or view it on GitHub
#362 (comment).

Jan Piper

@amaitland
Copy link
Member

@JPipe Thanks! Is there any urgency with this change? There is a major restructure happening related to JS Bindings, so I was going to see about bundling this change into those.

@JPipe
Copy link
Author

JPipe commented Jun 3, 2014

No Rush, I have included that code in my local build. On another note, I am
having trouble with bad resolution resolution (choppy text and Graphics),
is there a sample browserSettings you could point me to?

On Mon, Jun 2, 2014 at 7:31 PM, amaitland [email protected] wrote:

@JPipe https://github.com/JPipe Thanks! Is there any urgency with this
change? There is a major restructure happening related to JS Bindings, so I
was going to see about bundling this change into those.


Reply to this email directly or view it on GitHub
#362 (comment).

Jan Piper

@perlun
Copy link
Member

perlun commented Jun 10, 2014

@JPipe, are you using non-standard DPI (i.e. not 100%)?

@perlun
Copy link
Member

perlun commented Jun 10, 2014

Anyway, that seems like another issue so maybe we would be better off closing this one.

@amaitland
Copy link
Member

Closing issue due to inactivity, feel free to reopen if required.

@wiscow
Copy link

wiscow commented Jan 7, 2015

I am currently experiencing the same issue that @JPipe was experiencing. Is there any way to get the this to work using ElementHost.EnableModelessKeyboardInterop instead of ShowDialog. One of our requirements for our application is to not show the WPF portion of our applciation as a dialog. This is causing a major roadblock for us.

Thanks!

@sowrab1994
Copy link

I am facing this issue too. Opening a Wpf Window inside Winforms, not able to send any keystores to wpf window. I can't make it a Modal dialog due to requirement of application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cef3 wpf WPF Implementation
Projects
None yet
Development

No branches or pull requests

7 participants