Welcome Guest Search | Active Topics | Sign In | Register

Application using WebBrowser locks computer UI Options
Brad
Posted: Wednesday, August 9, 2017 2:31:55 PM
Rank: Newbie
Groups: Member

Joined: 8/9/2017
Posts: 4
While using the EO.WebBrowser, occasionally the screen will not accept input. Things like YouTube videos and interactive JavaScript object are still displaying and running, but clicking the mouse will not interact with the screen(moving the mouse will make the cursor move however). This goes for all of the screen and not just the application I wrote. To fix this I need to hit ctrl-alt-del and open task manager. This normally frees everything up. I am using the trial version of the WebBrowser so I don't know if this could cause it. I am using the afterReceiveHeaders, CertificateError, and LoadFailed events on the the webview object. For the afterReceiveHeaders event I grab a string from webpage text then send it to a delegate.

Thank You
*Edit: I now have a license for EO.Total and it did not cause a difference. I noticed this action seems to occur when I move/resize my application while the afterReceiveHeaders event is being fired
eo_support
Posted: Thursday, August 10, 2017 3:38:43 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Hi,

We are not aware of such issues, however this issue should be unrelated to the license. It MAY be related to your video card driver since usually such system wide lock up are caused by drivers, not by user application.

Another thing you can try to do is to run our TabbedBrowser sample application and see if the same problem occurs. One thing you can check is WebView is NOT multi-thread safe. In another word, you can not access/drive the same WebView through different threads. The following rules apply to WebView regarding threads:

1. One WebView is associated to one thread only;
2. Almost all calls to the WebView (with Destroy being one exception) must be called from that thread;
3. That thread must run a windows message loop to continuously pump windows message;

If you only create and use WebView through your main UI thread, then all the above conditions will be met. If you wish to create WebView through worker thread, then you must use the ThreadRunner class since that class runs a message pump to pump the messages for you.

If you still have problems, you can try to isolate the problem into a test project and send the test project to us. See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

Once we have that we will be happy to investigate further.

Thanks!
Brad
Posted: Thursday, August 10, 2017 5:46:12 PM
Rank: Newbie
Groups: Member

Joined: 8/9/2017
Posts: 4
Thank you for the reply,
I do not believe it is a video card issue because it happens on my clients and I's PC's. I tried the tabbed browser app and it works fine. I think I am running the WebView through the main UI thread, but I am still an amateur with threading and the .net stack. I am sending a test app that isolates the problem as I think it will be the easiest way to show/diagnose my problem. I am sending an email with the subject Test App(Topic: Application using WebBrowser locks computer UI).
Thanks Again,
Brad
eo_support
Posted: Friday, August 11, 2017 2:17:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Hi,

We have looked into the test project you sent to us, the root of the problem is you try to call WebView.GetHtml inside your AfterReceiveHeaders event handler. There are two serious issues with this:

1. Your page HTML is not ready yet. When the server sends a page back to the browser (in this case it sends the response to EO.WebBrowser), it sends header first before sending the body text. Immediately after the header is received, AfterReceiveHeaders is fired. At this point the body HTML has not been received yet. So when you try to get the page HTML at this stage you will run into a deadlock since browser engine won't be able to continue receive HTML until your AfterReceiveHeaders handler has returned; And your handler won't return until the browser engine has the HTML (there are cases where the HTML can be ready when AfterReceiveHeaders is fired, but that only happens sometimes. When that does not happen, your code will hang);

2. AfterReceiveHeaders is fired for EVERY request and there are usually MANY requests to load a single page. For example, if you have a simple HTML file that uses a single image, then the browser engine will issue one request to load the main HTML, then as it parses the main HTML and encounters the img tag, it will send another request to the server to fetch the image. Both requests will results a response from the server, and will trigger AfterReceiveHeaders. So you definitely should not handle AfterReceiveHeaders if you are just looking for something in the main page because this event is fired for every resource in the page;

So you must modify your code. I do not know exactly what you are trying to do but AfterReceiveHeaders is definitely not the right place for you.

Thanks!
Brad
Posted: Friday, August 11, 2017 2:39:28 PM
Rank: Newbie
Groups: Member

Joined: 8/9/2017
Posts: 4
Okay, The app actually works great as long as long as I do not move the form. The purpose of this program is to scrape data from an auction webpage while it is running. I then take the data(namely the stock number of the item on the block) and display data from our database that is relevant to that item.(i.e. our maximum bid, common damage, parts needed, etc.) I need to interact with the browser at two points. The first is when there is an iframe present that contains the running auction. I can not access the data in this Iframe because of cross-site scripting, but the main html for the website contains a link to the iframe that can be set as the URL for the webview. The second is when a new item appears on the block. I just need an event to trigger so the application knows when to grab the text off the page. I understand there are other events that I can play with, is there anything you would recommend to try based on this situation?
Thank You,
Brad
eo_support
Posted: Friday, August 11, 2017 4:49:00 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Hi,

You definitely can not use AfterReceiveHeaders to get the HTML in your case. AfterReceiveHeaders is a rather low level event and you need to return from this event as soon as possible to avoid potential deadlocks. The primary intention for this event is to allow you to examine the headers to look for entries of your interest. You should not do anything else in this event.

The cleanest way to do what you want to do is to:

1. Set WebView.JSInitCode to JavaScript that attaches an event handler to window.onload event. This is your own JavaScript code to be called once the page is loaded, including all the iframes. Inside your JavaScript code you can search for what you are interested in;

2. If you find what you need in your JavaScript onload handler, you can call into your C# code to perform further action. You will need to use JavaScript extension to do this. See here for more details:

https://www.essentialobjects.com/doc/webbrowser/advanced/jsext.aspx

3. Inside your C# side JavaScript extension function, use Control.BeginInvoke to invoke whatever you want to do. Do NOT call them directly. This is very important because this allows your JavaScript extension function to return immediately without having to wait for what you need to do to finish. If you do not return immediately, JavaScript engine will hang and your page will hang.

While working on your JavaScript, you may need to turn off cross site scripting off so that you can use JavaScript to access all iframes. You need to set this property to false:

https://www.essentialobjects.com/doc/eo.webengine.browseroptions.enablewebsecurity.aspx

See here for more information on how to use browser options:

https://www.essentialobjects.com/doc/webbrowser/advanced/browser_options.aspx

Hope this helps.

Thanks!

Brad
Posted: Friday, August 11, 2017 5:09:29 PM
Rank: Newbie
Groups: Member

Joined: 8/9/2017
Posts: 4
I really appreciate the help, I will work on that. Thank you again.
eo_support
Posted: Friday, August 11, 2017 6:28:28 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
No problem. That's what we do here. Please feel free to let us know if you need any more help.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.