Welcome Guest Search | Active Topics | Sign In | Register

Crash when disposing EO.WebView while page is still loading Options
Siemens
Posted: Thursday, February 11, 2021 2:31:19 AM
Rank: Newbie
Groups: Member

Joined: 12/7/2017
Posts: 9
We have a WPF application and loading a web page over a slow connection e.g. VPN might take longer.
When closing the view while loading I get a crash
Version: EO.Base, Version=20.3.34.0
This WebView either has already been destroyed or is being destroyed.
EO.Base.Runtime.itno(System.Object, System.Exception, Boolean)
EO.WebBrowser.WebView.nwgo(System.Exception, Boolean)
EO.WebBrowser.WebView.nwct(Boolean)
EO.WebBrowser.WebView.nwgw(EO.WebBrowser.WaitableTask, Boolean)
EO.WebBrowser.WaitableTask.ippz(EO.WebBrowser.WebView, Boolean)
EO.WebBrowser.NavigationTask..ctor(EO.Internal.ietr, EO.Internal.rhuo, System.String, System.String, EO.WebBrowser.Request,
EO.WebBrowser.WebView+nhec.nwdc(System.String, System.String, Boolean)
EO.WebBrowser.WebView.ywwe()
EO.WebBrowser.WebView.mmom()
EO.WebBrowser.WebView.nwco(Boolean)
EO.WebBrowser.WebView.Destroy()
System.ComponentModel.Component.Dispose()

The original code looked like this.
Code: C#
Load()
            EO.WebBrowser.Request request = new EO.WebBrowser.Request(webContext.TargetURI.AbsoluteUri);
            request.PostData.SetRawData(webContext.PostData);
            request.Method = "POST";
            this.webBrowser.LoadRequest(request);

protected virtual void Dispose(bool disposing)
{
  if (this.webBrowser != null)
  {
      this.webBrowser.Dispose();


Investigating I found out that this only happens if the page is not loaded fully

Code: C#
protected virtual void Dispose(bool disposing)
{
  if (this.webBrowser != null)
  {
    //In case async loading
    int nrOfRetries = 10;
    while (this.webBrowser.IsLoading && nrOfRetries > 0)
    {
      Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "Waiting for load to be complete: retries left {0}", nrOfRetries));
      this.webBrowser.StopLoad();
      Thread.Sleep(1000);
      nrOfRetries--;
    }
    if (this.webBrowser.IsCreated && this.webBrowser.IsReady)
    {
      this.webBrowser.Dispose();


StopLoad() does not cancel the load operation as I would have expected.
It stops loading, but then IsLoading will be always true, (I tried with 1000 :))
What is the correct sequence to shut down a view with a webcontrol while the page has not finished loading
eo_support
Posted: Thursday, February 11, 2021 10:52:40 AM
Rank: Administration
Groups: Administration

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

You only need to call WebView.Destroy. That will property dispose the WebView in an orderly fashion. It won't clean up everything right away because a lot of internal tasks are done asynchronously. However you can safely discard the WebView after you called WebView.Destroy, the corresponding request objects will be cancelled as soon as possible.

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.