Multiple browsers with multiple threads in single process

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.

Multiple browsers with multiple threads in single process

Postby Arturo » Fri Apr 24, 2015 1:30 pm

Hey All,

I'm a bit new to CEF so I thought I might seek some help.
I am currently using CEF on Windows and just for testing purposes am using CEF's OSR capabilities so there are no windows involved.

Keep in mind I am using 'single_process' set to true.

I currently have a function which creates a new CefApp (which creates a new browser via CreateBrowser on 'OnContextInitialized'), a new CefClient, calls CefInitialize and then calls CefRunMessageLoop().

I have spawned two different windows threads with that function, everything seems to go fine until my app crashes on CefRunMessageLoop with: 'context.cc(173) Check failed: false. called on invalid thread'

This seems to be triggered when CefRunMessageLoop is called on a different thread than the thread I called CefInitialize on, but from what I can see my function calls CefRunMessageLoop directly after CefInitialize, and since I spawned two different threads they should all be called on different UI threads, but it seems they are not.

Could anyone guide me as to what I am missing here?
Arturo
Newbie
 
Posts: 3
Joined: Fri Apr 24, 2015 11:48 am

Re: Multiple browsers with multiple threads in single proces

Postby magreenblatt » Fri Apr 24, 2015 1:58 pm

CefInitialize and CefRunMessageLoop should only be called a single time on the main application thread. You can then call CreateBrowser multiple times to create multiple browsers. You should not use single-process mode.
magreenblatt
Site Admin
 
Posts: 12406
Joined: Fri May 29, 2009 6:57 pm

Re: Multiple browsers with multiple threads in single proces

Postby Arturo » Fri Apr 24, 2015 5:37 pm

I am currently working on a way to avoid using single process mode but assuming I won't be able to pull that off, does CEF support re-using CefApp and CefClient instances in a single process?
If not, is re-using CefApp and CefCient supported in a multi process architecture or do I still have to create a different CefApp and CefClient for each browser? Am I guaranteed that each browser I create will spawn a new process? Otherwise I might stumble on the same issue.
Arturo
Newbie
 
Posts: 3
Joined: Fri Apr 24, 2015 11:48 am

Re: Multiple browsers with multiple threads in single proces

Postby magreenblatt » Sat Apr 25, 2015 2:15 am

CefApp is shared by the whole application and is not specific to a particular browser. CefClient can be shared by multiple browsers. You should read the Tutorial or GeneralUsage wiki pages for a better understanding.
magreenblatt
Site Admin
 
Posts: 12406
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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