|
Rank: Advanced Member Groups: Member
Joined: 12/9/2014 Posts: 79
|
Hi. I use WebView directly, using WebView.Create(handle) as show documentation. Until version 2015.2.65.0 aproximately, I recreate WebViews to clean session without problems. I do:
Code: C#
//Destroy actual webview
m_WebView.Dispose();
m_WebView = null;
//Shutdown
EO.Base.Runtime.Shutdown();
//I see in another post but i think it is not necessary
GC.Collect();
GC.WaitForFullGCComplete();
GC.WaitForPendingFinalizers();
//Recreate
m_WebView = new EO.WebBrowser.WebView();
m_WebView.Create(this.Handle);
//Events etc.
...
Between versions 2015.2.65.0 and 2015.2.85.0, calling .Create after Shutdown simply crash(and crash my app). Between versions 2015.2.88.0 and 2015.3.1.0 (I download before this post), call to .Create still fail, but not crash, throws an Exception with a message similar to: "Operation can not be completed because Shotdown has been called" Thanks in advance.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
This is normal. Shutdown is a one time irreversible operation. It calls the same clean up code that will be automatically called when your AppDomain is being unloaded or when your process exits. Once this clean up code is called, you can not longer do anything related to EO controls in that AppDomain.
Generally you should never call Shutdown explicitly since it will automatically called anyway. The original purpose of this method is for plugins. Some users use EO.WebBrowser to create plug-ins and the host application for those plug-ins do not always clean up things nicely. For those cases, it would save resources if Shutdown is called when the plugin is no longer needed.
If you must somehow shutdown all EO resources before your application exits, you can use a separate AppDomain to house all EO components. When you no longer need it you can simply call AppDomain.Unload to unload that app domain. That will call the same clean up code Shutdown calls. If you need EO components again, you can do so again with a new AppDomain.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/9/2014 Posts: 79
|
Ok, got it.
Previously, Shutdown was not irreversible operation. You "recommed" as a way to destroy all webviews to clean session before recreate webviews without exit application or change AppDomain. In fact, this is working in my app until version 65 as i say before.
I understand that now you change this. How should I clean session? The use of one section of one of my apps is simply. Is a form with a Webview and a control to select digital certificate. Everytime that user select a different certificate, I destroy webview, shutdown and recreate to force to throw NeedClientCertificate event and pass the new certificate when Navigate to a URL.
Any advice?
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
There is no easy way to do this in the current version without unloading your AppDomain. You can try this sequence and see if it works for you:
1. Destroy all WebViews in your application; 2. You will see only two rundll32.exe left running (when your WebView is running you will have more); 3. Wait for about 5 seconds, one of them will exit;
Now if you recreate another WebView, a number of new rundll32.exe will starts and the previous certificate state should have been cleared since this is held in memory by the rundll32.exe process in step 3. This process corresponds to a single instance of the "browser engine".
If you do not wish to wait for step 3, then your best and only option is to unload your AppDomain.
We are working on adding API that would allow you to have multiple engines in a single AppDomain and to control them individually. This will allow you to support "incognito" mode that each engine will have their own isolated data. You will also have the option to shutdown each engine individually without having to unload the whole AppDomain. Once that is done, you will be able to use that option.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/9/2014 Posts: 79
|
Thank you very much for your support and advices.
I'll try your steps and see if it works.
You tell me about isolation in another post (feature request), its very interesenting for me, and I waiting it. When you have a beta version, if you want I can help you testing it.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/9/2014 Posts: 79
|
Hi all. The steps provided works, but i dont wait 5 sec. In CreateWebView method I set webview.UnloadDelay = 0. My working ResetSession now is (I call CreateWebView() in Init first):
Code: C#
public void ResetSession()
{
m_WebView.Dispose();
m_WebView = null;
Application.DoEvents();
CreateWebView();
}
I discover that I need Application.DoEvents. Without DoEvents, the webview is not showing, and I fix calling ResetSession twice. But this is weird. Later, doing some tests, I discover that if I put MessageBox before create new WebView, the WebView shows, and try DoEvents and shows too. I dont know exactly why, but with DoEvents all works fine. Hope that this can help to someone. Thanks a lot. Regards.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Thanks for the update. What you discovered makes sense. Setting UnloadDelay to 0 will remove one stage of the waiting process. And you need to pump messages in order for the WebView to function since many internal works of the WebView relies on the message pump. It is recommended that you call this method instead (in case Application.DoEvents is not available to you): http://www.essentialobjects.com/doc/eo.webbrowser.webview.doevents_overloads.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/9/2014 Posts: 79
|
Thanks a lot for the information and explanations.
I'll try those method.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
We have posted a new build with multiple engine support that you may find useful for your scenario. Please see your private message for the download location.
In this build we had to move BrowserOptions from EO.WebBrowser namespace to EO.WebEngine namespace. So if you use that class, you may run into compiler error, which you will need to adjust your code.
You can check the "EO.WebBrowser -> Advanced Topics -> Managing Browser Engine" topic to find more details on how to use multiple browser engines.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/9/2014 Posts: 79
|
Thank you very much!
Downloading new version ....
I'll test as soon as possible and write feedback.
|
|