Welcome Guest Search | Active Topics | Sign In | Register

EO.WebBrowser Options
Mork
Posted: Friday, November 3, 2017 5:15:20 PM
Rank: Newbie
Groups: Member

Joined: 3/28/2017
Posts: 5
I'm using the EO.WebBrowser (great product, btw!) with a very large JS file (> 20 Mb minified). Not surprisingly, it takes a long time to load the JS. I'd like to create a WebControl/WebView instance in advance and reuse it to improve performance. Creating the WebView in a hidden window works fine, but when I try to switch the WebControl to a new window (from the hidden window), it seems to force a reload of the webView. The HTML (set with LoadHtml) also seems to be lost when the control is moved to a new window.

Is there a way to move a WebControl to a new window and prevent the reload? If not, is there a different technique for initializing and then reusing WebControl?

Please note that in this application, I don't have control over the window to which the WebControl will be moved -- the target window is created by the application and WebControl (part of a UserControl) is then added to the new window.
eo_support
Posted: Friday, November 3, 2017 5:41:11 PM
Rank: Administration
Groups: Administration

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

How do you move the webControl to the new window?

Thanks!
Mork
Posted: Friday, November 3, 2017 5:48:40 PM
Rank: Newbie
Groups: Member

Joined: 3/28/2017
Posts: 5
eo_support wrote:
Hi,

How do you move the webControl to the new window?

Thanks!


The WebControl is removed from the list of Controls in the off-screen form, and added to a user control.

WebControl webControl = offscreenForm.Controls[0];
offscreenForm.Remove(webControl);

userControl.Controls.Add(webControl);
eo_support
Posted: Friday, November 3, 2017 5:58:55 PM
Rank: Administration
Groups: Administration

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

Try to use this method and see if it helps:

https://www.essentialobjects.com/doc/eo.webbrowser.webview.preload_overload_2.aspx

You will need to call Preload in the UI thread and then later set the WebControl's WebView property to the preloaded WebView.

The possible problems can be:

1. The original WebView in off-screen form is NOT initialized until the form is displayed. The Preload method will avoid this issue for you;
2. You may have JavaScript code in the page that is triggered by user events (for example, mouse move, onsize, etc) and takes a long time handling those events. If this is the case, the only way is to adjust your code since the browser will always invoke those handlers faithfully;

Thanks!
Jack
Mork
Posted: Friday, November 3, 2017 6:19:48 PM
Rank: Newbie
Groups: Member

Joined: 3/28/2017
Posts: 5
That's an excellent idea, but the current overloads don't quite match my use case. The webView I'm using has a custom ResourceHandler assigned, and I'm using LoadHtml to assign the html as there's no server in this context. Is there any way I can use the Preload using these constraints?

BTW, I checked the off-screen page by displaying the form on-screen. It loads and renders correctly. The webView must call reload when the webControl is moved -- WebView.IsLoadingChanged is fired after the move.
eo_support
Posted: Monday, November 6, 2017 1:45:02 PM
Rank: Administration
Groups: Administration

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

Can you create a small test app and send the test app to us? The WebView should retain its states in this case. Please see here for more information on how to send the test app to us:

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

Thanks!


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.