cefsharp / Questions-and-Support

Use this repository to ask CefSharp specific questions
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Random Crash in CreateBrowser() #56

Closed kapilkumar6 closed 3 years ago

kapilkumar6 commented 4 years ago

I see a random crash in my application based on CEFSharp. It's not easy to reproduce and seen this crash stack everytime. Random Crash in CreateBrowser() at CefSharp.WinForms.ChromiumWebBrowser.CreateBrowser() at CefSharp.WinForms.ChromiumWebBrowser.OnHandleCreated(EventArgs e) at System.Windows.Forms.Control.WmCreate(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Note: In the current version of my application, Creation of ChromiumInstance happens in UI Thread, but disposal happens in the background thread. I am changing the disposal in the UI thread too with a dispatcher with background thread priority.

I see a similar issue: https://github.com/cefsharp/CefSharp/issues/2979

amaitland commented 4 years ago

It's not easy to reproduce and seen this crash stack everytime.

Make sure you have the .pdb files next to the .dll files, you need a proper stack trace.

You need

  • What version of the product are you using? -71.0.2

This version is very old and unsupported. In future please only open a bug report if you can reproduce the problem with the current supported version (84.4.10 at time of writing).

but disposal happens in the background thread.

This is not supported, you must call Dispose on the UI Thread.

  • if using the same thread for creation/disposal, Will this solve the problem?

Impossible to say without an example that reproduces your problem. There's not enough information to speculate.

Your issue has been transferred to https://github.com/cefsharp/Questions-and-Support as you are using an old unsupported version and Disposing on a non UI Thread is open to race conditions.

kapilkumar6 commented 4 years ago

Thanks for the quick update, please see my response below:

An actual exception type, is this a null reference? Something else? ->yes, its Null Pointer (Object reference not set to an instance of an object.) I am guessing either BrowserSettings or ManagedCefBrowserAdapter is Null. Maybe because disposal happened before Createrowser could finish? (as currently, it was on different threads)

Line numbers, need to know where the exception is actually happening. ->Unfortunately crash dump is not giving an exact line number, as my application catches all exceptions and later on shows a customize error dialog to the user.

This version is very old and unsupported. In future please only open a bug report if you can reproduce the problem with the current supported version (84.4.10 at time of writing). ->yes, I have upgraded to 84. but before the release, I wanted to check if it's possible to find the exact root cause.

This is not supported, you must call Dispose on the UI Thread. ->yes, i have changed the disposal to UI thread now.

Thanks for the quick inputs though, will keep a close eye on this.

amaitland commented 4 years ago

I am guessing either BrowserSettings or ManagedCefBrowserAdapter is Null. Maybe because disposal happened before Createrowser could finish? (as currently, it was on different threads)

In version 84 you will get an ArgumentNullException if BrowserSettings is null.

->Unfortunately crash dump is not giving an exact line number, as my application catches all exceptions and later on shows a customize error dialog to the user.

Log the exception to disk, use a central server to capture crash reports, log the errors to the event log. Do something to capture the full stack trace. Your loosing valuable information.

->yes, I have upgraded to 84. but before the release, I wanted to check if it's possible to find the exact root cause.

Write some unit/integration tests to create/dispose of the browser in a loop, test before and after your changes to confirm the issue is resolved.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.