Can't Wait() on CefWaitableEvent synchronization object

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.

Can't Wait() on CefWaitableEvent synchronization object

Postby user6294 » Mon Feb 22, 2021 5:49 pm

Hi

CefCookieManager I/F usage (58 => 79 upgrade, callbacks switched to UI thread from IO thread)

I'm following the example in ceftests, which I notice invokes the CefCookieManager::GetGlobalManager() on the IO thread, where as in our
upgraded CEF 79 App CefCookieManager::GetGlobalManager() is invoked on the UI thread.

The problem I'm having is event->Wait(); it doesn't block like in the ceftest harness
(wait until Completion callback fires which sets the CefWaitableEvent event object) and the only difference I can see is above.

Q. What am I doing wrong

Many Thanks

Can't wait on CefWaitableEvent synchronization object

chromium\src>out\Debug_GN_x64\ceftests.exe --gtest_filter=CookieTest.BasicDomainCookie

TID Main/UI : 21048
TID IO : 5512

00000001 20:50:22.104 [18096] [21048] 172 ::CefExecuteProcess(args, application, windows_sandbox_info)
. . .
. . .
00000012 20:50:22.292 [18096] [5512] 516 ::TestBody()
00000013 20:50:22.292 [18096] [5512] 312 CefCookieManager::GetGlobalManager()
00000014 20:50:22.292 [18096] [5512] 316 CefCookieManager::GetGlobalManager(context * 0x0000000002B76960)
00000015 20:50:22.292 [18096] [5512] 105 CefCookieManagerImpl::CefCookieManagerImpl()
00000016 20:50:22.292 [18096] [5512] 116 CefCookieManagerImpl::Initialize()
00000017 20:50:22.292 [18096] [21048] 42 anon_ns::TestCompletionCallback::OnComplete()
00000018 20:50:22.293 [18096] [5512] 524 ::TestBody() calling event->Wait(), CefCookieManager * 0x000000000298E5A0
00000019 20:50:22.293 [18096] [5512] 529 ::TestBody() returned from event->Wait(), CefCookieManager * 0x000000000298E5A0

// On IO Thread
TEST(CookieTest, BasicDomainCookie) {

CefRefPtr<CefWaitableEvent> event = CefWaitableEvent::CreateWaitableEvent(true, false);

CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(new TestCompletionCallback(event));

event->Wait(); // <=== this blocks (works)



Our CEF 79.x App

TID Main/UI : 21656
TID IO : 5512

00000383 21:41:20.782 [18356] [21656] 312 CefCookieManager::GetGlobalManager()
00000384 21:41:20.783 [18356] [21656] 316 CefCookieManager::GetGlobalManager(context * 0x0000000000DAE080)
00000385 21:41:20.783 [18356] [21656] 105 CefCookieManagerImpl::CefCookieManagerImpl()
00000386 21:41:20.783 [18356] [21656] 116 CefCookieManagerImpl::Initialize()

00000412 21:41:20.837 [18356] [21656] 845 AsyncCompletionCallback::OnComplete()

class AsyncCompletionCallback : public CefCompletionCallback {
public:
explicit AsyncCompletionCallback(CefRefPtr<CefWaitableEvent> event) : event_(event) {
}
void OnComplete() override {
event_->Signal(); // allow 1 thread to run
}

// On Main/UI Thread
MyCefApp() {

CefRefPtr<CefWaitableEvent> event = CefWaitableEvent::CreateWaitableEvent(true, false);

CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(new AsyncCompletionCallback(event));

event->Wait(); // <=== this doesn't block ?
user6294
Mentor
 
Posts: 83
Joined: Sun Mar 18, 2018 6:57 pm

Re: Can't Wait() on CefWaitableEvent synchronization object

Postby magreenblatt » Mon Feb 22, 2021 6:05 pm

What am I doing wrong

Don’t block CEF threads outside of tests.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Can't Wait() on CefWaitableEvent synchronization object

Postby user6294 » Mon Feb 22, 2021 6:22 pm

So why did it work in CEF 58.x, we setup

CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(NULL);

on UI (main) thread, and then also waited/blocked on main/UI thread, and callback fired on IO thread

So if I wanted to stick to this pattern, do I create my own raw WIN32 thread to setup in and thus
block/wait in my own WIN32 thread, and let the callback fire on IO thread

thanks
user6294
Mentor
 
Posts: 83
Joined: Sun Mar 18, 2018 6:57 pm

Re: Can't Wait() on CefWaitableEvent synchronization object

Postby magreenblatt » Mon Feb 22, 2021 6:47 pm

What, specifically, are you waiting for, and why? Consider using the async callbacks instead.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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

cron