Mac OSX off-screen rendering thread

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Mac OSX off-screen rendering thread

Postby phronmophobic » Fri Mar 12, 2021 1:05 pm

For offscreen rendering on OSX, are cef_* calls required to be on the main thread (ie. thread 1) or is it enough to ensure that all cef_* calls originate from the same thread?
phronmophobic
Newbie
 
Posts: 8
Joined: Fri Feb 19, 2021 5:53 pm

Re: Mac OSX off-screen rendering thread

Postby magreenblatt » Fri Mar 12, 2021 2:03 pm

It depends on the function. Check the documentation.
magreenblatt
Site Admin
 
Posts: 12379
Joined: Fri May 29, 2009 6:57 pm

Re: Mac OSX off-screen rendering thread

Postby phronmophobic » Fri Mar 12, 2021 5:34 pm

I can't find anywhere in the documentation where it distinguishes between "a" main thread vs "the" main thread (ie. the Mac OSX thread 1).

I find several terms in the comments, but I can't find anywhere that specifies which, if any, refer to the special thread 1 on Mac OSX.
- browser process main thread
- main thread
- render process main thread
- main thread (TID_RENDERER)
- UI thread
- browser process UI thread

In addition to the source code comments, the guides don't seem to distinguish between the two either:

https://bitbucket.org/chromiumembedded/ ... er-threads
It defines the main thread is the thread that cef_initialize is called on, but does not say whether it must be thread 1 on Mac OSX.

The comment for cef_initialize says "This function should be called on the main application thread to initialize", but does not specify whether it should be thread 1.

According to https://developer.apple.com/library/arc ... mmary.html, most everything can be used from "a" main thread (ie. not thread 1) except for NSView and event handling. It seems like that should allow for an application that uses offscreen rendering to run everything on "a" main thread, but it would be great to have a clearer answer.

Thanks,
phronmophobic
Newbie
 
Posts: 8
Joined: Fri Feb 19, 2021 5:53 pm

Re: Mac OSX off-screen rendering thread

Postby magreenblatt » Fri Mar 12, 2021 5:51 pm

The "main thread" is the thread that main() is called on. That is probably also "thread 1" in most cases. The main thread will also be the UI thread, except when CefSettings.multi_threaded_message_loop is set to true (this setting is not supported on MacOS).

I don't know what multiple "main threads" would mean on MacOS. Do you gave a specific system API in mind?
magreenblatt
Site Admin
 
Posts: 12379
Joined: Fri May 29, 2009 6:57 pm

Re: Mac OSX off-screen rendering thread

Postby phronmophobic » Fri Mar 12, 2021 5:58 pm

The goal isn't to have multiple main threads. The goal would be to run all of the browser work off of thread 1 so that thread 1 can be free to do only tasks that must absolutely be run on thread 1.

All of the browser work would still only be called from a single thread, it just wouldn't be thread 1. It also allows applications to simply use cef_run_message_loop rather than integrating cef_do_message_loop_work/on_schedule_message_pump_work into their application.
phronmophobic
Newbie
 
Posts: 8
Joined: Fri Feb 19, 2021 5:53 pm

Re: Mac OSX off-screen rendering thread

Postby magreenblatt » Fri Mar 12, 2021 6:32 pm

That’s not possible for the NSView and event handling reasons you mention above.
magreenblatt
Site Admin
 
Posts: 12379
Joined: Fri May 29, 2009 6:57 pm

Re: Mac OSX off-screen rendering thread

Postby phronmophobic » Fri Mar 12, 2021 7:26 pm

In theory, it seems like those restrictions might not apply in the case of off-screen rendering. Initial tests haven't crashed when running cef off of thread 1.
phronmophobic
Newbie
 
Posts: 8
Joined: Fri Feb 19, 2021 5:53 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 3 guests