MacOS calls CEF when using external message loop

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

MacOS calls CEF when using external message loop

Postby tarmac » Tue Nov 08, 2022 5:26 am

Hello,

I'm trying to set up CEF with an external message loop on macOS. However, my application's
Code: Select all
[NSApp run]
seems to lead to CEF's runloop observer to get called:

Code: Select all
[1108/110141.158472:FATAL:message_pump_mac.mm(402)] Check failed: nesting_level_ != 0 (0 vs. 0)

(lldb) bt
* thread #1, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x110ddb1c4)
  * frame #0: 0x0000000110ddb1c4 Chromium Embedded Framework`logging::LogMessage::~LogMessage(this=0x0000000103e99640) at logging.cc:951:7 [opt]
    frame #1: 0x0000000110ddb44c Chromium Embedded Framework`logging::LogMessage::~LogMessage() [inlined] logging::LogMessage::~LogMessage(this=<unavailable>) at logging.cc:702:27 [opt]
    frame #2: 0x0000000110ddb448 Chromium Embedded Framework`logging::LogMessage::~LogMessage(this=<unavailable>) at logging.cc:702:27 [opt]
    frame #3: 0x000000010ca8ddf0 Chromium Embedded Framework`scoped_refptr<CefCommandLineImpl>::~scoped_refptr() [inlined] scoped_refptr<CefCommandLineImpl>::Release(ptr=<unavailable>) at scoped_refptr.h:361:8 [opt]
    frame #4: 0x000000010ca8dde4 Chromium Embedded Framework`scoped_refptr<CefCommandLineImpl>::~scoped_refptr() [inlined] scoped_refptr<CefCommandLineImpl>::~scoped_refptr(this=0x000000016fdfe248) at scoped_refptr.h:261:7 [opt]
    frame #5: 0x000000010ca8dddc Chromium Embedded Framework`scoped_refptr<CefCommandLineImpl>::~scoped_refptr(this=0x000000016fdfe248) at scoped_refptr.h:254:20 [opt]
    frame #6: 0x0000000110ea063c Chromium Embedded Framework`base::MessagePumpCFRunLoopBase::PopWorkItemScope(this=0x000000010379e240) at message_pump_mac.mm:402:3 [opt]
    frame #7: 0x0000000110ea01cc Chromium Embedded Framework`base::MessagePumpCFRunLoopBase::EnterExitObserver(observer=<unavailable>, activity=128, info=0x000000010379e240) at message_pump_mac.mm:677:13 [opt]
    frame #8: 0x00000001aafc1bb0 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
    frame #9: 0x00000001aafc1a00 CoreFoundation`__CFRunLoopDoObservers + 592
    frame #10: 0x00000001aafc04e4 CoreFoundation`CFRunLoopRunSpecific + 684
    frame #11: 0x00000001b3be0dd8 HIToolbox`RunCurrentEventLoopInMode + 292
    frame #12: 0x00000001b3be0b54 HIToolbox`ReceiveNextEventCommon + 564
    frame #13: 0x00000001b3be0908 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 72
    frame #14: 0x00000001adb1fbcc AppKit`_DPSNextEvent + 860
    frame #15: 0x00000001adb1e4c4 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1328
    frame #16: 0x00000001adb10690 AppKit`-[NSApplication run] + 596
    frame #17: 0x00000001000392f4 cefclient`_sapp_macos_run(desc=0x000000016fdfed60) at sokol_app.h:3347:5
    frame #18: 0x0000000100039078 cefclient`main(argc=1, argv=0x000000016fdff168) at sokol_app.h:3356:5
    frame #19: 0x0000000100201088 dyld`start + 516


(Please note that this is a different program than the `cefclient` in the repo. I called my macOS app bundle `cefclient` just so that I could just copy over the `cefclient Helper`s)

Do I need to make any changes to my application to setup CEF with an external message loop? eg. does CEF make any assumptions about how my application's message loop runs?
tarmac
Newbie
 
Posts: 9
Joined: Tue Nov 08, 2022 5:08 am

Re: MacOS calls CEF when using external message loop

Postby magreenblatt » Tue Nov 08, 2022 10:34 am

You still need to implement the CefAppProtocol interface when using external message loop. If you can't implement it directly, there's an example in injection here that you can follow.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: MacOS calls CEF when using external message loop

Postby magreenblatt » Fri Jul 28, 2023 10:21 am

How does your application create the NSApplication instance currently? It would be easiest to follow the cefsimple code example.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 207 guests