Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CEF.Shutdown gives unexpected result: debug assertion or infinite lock! #2

Closed
ghost opened this issue Dec 8, 2010 · 8 comments
Closed

Comments

@ghost
Copy link

ghost commented Dec 8, 2010

Now call to CEF.Shutdown gives unexpected result: debug assertion or infinite lock.
Not usable at this moment...
I think, it is CEF-related, not CefSharp-related bug.

@chillitom
Copy link
Contributor

at a guess this is because of ref counting, because the managed objects still hold references to CEF ref counted objects. Calling CEF.Shutdown before those managed objects are garbage collected leads to this error.

Do you still get the error if you release all objects and calling System.GC.Collect(); and System.GC.RunFinalizers(); before Shutdown?

A release build of libcef_dll_wrapper might fix this as the assertions probably wouldn't run.

@ghost
Copy link
Author

ghost commented Dec 8, 2010

Thanks!

Yes, it solves problem, CEF.Shutdown no more locks, but now i got unhandled exception:

Application: LS.Cards.Shell.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
at System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle)
at System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)
at System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])
at LS.Cards.Shell.Core.CardsBrowser.OnNavigated(LS.Cards.Shell.Core.CardsBrowserNavigatedEventArgs)
at LS.Cards.Shell.WebKit.WebKitCardsBrowser.browser_Navigated(System.Object, System.String)
at LS.Cards.Shell.WebKit.WebKitCardsBrowser.browser_PropertyChanged(System.Object, System.ComponentModel.PropertyChangedEventArgs)
at CefSharp.BrowserControl.raise_PropertyChanged(System.Object, System.ComponentModel.PropertyChangedEventArgs)
at CefSharp.BrowserControl.SetNavState(Boolean, Boolean, Boolean)
at .CefSharp.HandlerAdapter.HandleLoadEnd(CefSharp.HandlerAdapter_, CefRefPtr_, CefRefPtr*)

It looks, as my fault. Now i need some refactoring in my code, 'cause my browser-wrapper instantiated in app form, - may be better do Init/Finit outside Form.

@ghost
Copy link
Author

ghost commented Dec 8, 2010

I rewrite some pieces of code, no locks occured, but assertion is fired...
No ideas. :(

@ghost
Copy link
Author

ghost commented Dec 8, 2010

I do internal refactoring in my app - problem not resolved:
Assert message happens twice on CefShutdown:
Assertion failed!

Program: ...
File: .\libcef_dll\wrapper\libcef_dll_wrapper.cc
Line: 41

Expression: CefHandlerCppToC::DebugObjCt == 0

Same result i give on CefTest app, after modifying Program.cs:
Application.Run(browser);

        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
        GC.WaitForPendingFinalizers();

        CEF.Shutdown();

@ghost
Copy link
Author

ghost commented Dec 8, 2010

Sorry my mistake - two assertions:

  1. File: .\libcef_dll\wrapper\libcef_dll_wrapper.cc
    Line: 41
    Expression: CefHandlerCppToC::DebugObjCt == 0
  2. File: .\libcef_dll\wrapper\libcef_dll_wrapper.cc
    Line: 47
    Expression: CefBrowserCToCpp::DebugObjCt == 0

I call BrowserControl.Dispose directly and this assertion any way happens.
So i think that it is CefSharp issue.
I tried to fix it - but my expirience in C++/CLI is poor - i'm something don't understand, some of destructors - not called...

@NeomMob
Copy link

NeomMob commented Jan 17, 2011

Hello,
Do you have any new about this relly ennoying issue?
Thanks and regards,

@ghost
Copy link
Author

ghost commented Jan 17, 2011

Hello.
Yes, new version (not in master branch) can free some resources more aggressively, so it can be freed more accuracy.
With current version you can also shutdown cef without assertion by free (dispose) CefWebBrowser first, and then do full gc collect, and then call shutdown. Now it works for me completely.

@ataranto ataranto closed this as completed Mar 7, 2013
mwisnicki pushed a commit to mwisnicki/CefSharp that referenced this issue May 29, 2013
Undo VS2010/VS2012 project split and use conditional elements when neede...
@perlun
Copy link
Member

perlun commented Aug 3, 2013

(ignore that comment, it refers to a pull request numbering in the perlun fork...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants