|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
How do you move the webControl to the new window?
Thanks!
|
|
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);
|
|
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.aspxYou 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
|
|
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.
|
|
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.aspxThanks!
|
|