Hi mojo experts,
I'm having trouble calling mojo from a ThreadPool thread and appreciate your advice.
Loading fonts to the renderer process is expensive, often ~15% of the total layout time. I'm trying to move this out of the main thread.
main_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&BindHostReceiverOnMainThread,
font_proxy.BindNewPipeAndPassReceiver()));
The execution of this code, and therefore following the actual mojo calls, seem to be delayed until sometime -- I guess probably the main thread goes back to the event loop. This is causing two problems:
- The font loading doesn't start at the point I wish to start.
- When the main thread tries to read the loaded font, it hits a deadlock.
Now I'm thinking, if I use a WorkerTherad instead of ThreadPool, and post the BindHostReceiver task earlier (when the main thread can run posted tasks), actual mojo calls may be able to run without requiring the main thread to go back to the event loop.
Does my observation and hypothesis seem to be correct? Can anyone see other advice?
Your support is greatly appreciated in advance.