I'm making a fair amount of progress integrating CEF3 into the cinder framework, but I've been racking my brain trying to solve an EXC_BAD_ACCESS during CefShutdown(), using cef_binary_3.1547.1412_macosx32. I was able to follow what cefclient does for a while, but I couldn't do the same for the message loop, I need to use CefDoMessageLoopWork() during cinder's App::update() instead.
I'm a bit out of hints as to what it can be, but I'll list what I know. Here is the relavant stacktrace:
- Code: Select all
* thread #1: tid = 0x81f482, 0x9710545a libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 466, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x10)
frame #0: 0x9710545a libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 466
frame #1: 0x92eb4cdf CoreFoundation`_CFAutoreleasePoolPop + 47
frame #2: 0x9084d934 Foundation`-[NSAutoreleasePool drain] + 122
frame #3: 0x02cfefa8 libcef.dylib`base::mac::ScopedNSAutoreleasePool::~ScopedNSAutoreleasePool() + 56
frame #4: 0x02cfef4b libcef.dylib`base::mac::ScopedNSAutoreleasePool::~ScopedNSAutoreleasePool() + 43
frame #5: 0x072df5b4 libcef.dylib`base::DefaultDeleter<base::mac::ScopedNSAutoreleasePool>::operator()(base::mac::ScopedNSAutoreleasePool*) const + 68
frame #6: 0x072df53a libcef.dylib`base::internal::scoped_ptr_impl<base::mac::ScopedNSAutoreleasePool, base::DefaultDeleter<base::mac::ScopedNSAutoreleasePool> >::reset(base::mac::ScopedNSAutoreleasePool*) + 122
frame #7: 0x072df319 libcef.dylib`scoped_ptr<base::mac::ScopedNSAutoreleasePool, base::DefaultDeleter<base::mac::ScopedNSAutoreleasePool> >::reset(base::mac::ScopedNSAutoreleasePool*) + 57
frame #8: 0x072df27b libcef.dylib`content::ContentMainRunnerImpl::Shutdown() + 715
frame #9: 0x0717027d libcef.dylib`CefContext::FinalizeShutdown() + 125
frame #10: 0x0716f444 libcef.dylib`CefContext::Shutdown() + 676
frame #11: 0x0716f0d1 libcef.dylib`CefShutdown() + 561
frame #12: 0x00e646c8 libcef.dylib`cef_shutdown + 40
* frame #13: 0x0053cab4 CinderCefTest`CefShutdown() + 36 at libcef_dll_wrapper.cc:164
frame #14: 0x00018cb0 CinderCefTest`cstage::WebEngine::shutdown(this=0x1358dbd0) + 48 at WebEngine.cpp:340
Profiling with NSZombies didn't reveal anything, so I think it has to do with memory management on my end, however my CefApp / CefClient impl is implementing CEF's automatic reference counting, so I don't know.
I saw the order of steps listed in CefLifeSpanHandler::DoClose() and I am trying my best to adhere to the recommended method: When the app signals a shouldClose(), I close the main (and only) CefBrowser and return false to cancel. I notice DoClose being called, and I also call GetHost()->ParentWindowWillClose(). Finally, with no windows left open in my application, I close it from the menu and I still receive the same crash traced above.
Only other thing I can note is that if I don't call CefShutdown() at all, I receive a similar crash that leads back to an exc_bad_access from AutioreleasePoolPage::pop() on something named 'CrBrowserMain'.
Any suggestions to fix or further debug this are much appreciated, and thanks to those responsible for this framework!
cheers,
Rich