CEF1: Possible race condition with CefGetWebPluginInfo?

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.

CEF1: Possible race condition with CefGetWebPluginInfo?

Postby ScottKevill » Wed Jan 02, 2013 11:46 pm

Immediately after CefInitialize(), I post a task to the UI thread to CefGetWebPluginInfo("Shockwave Flash"), but sometimes for some users it fails to detect their Flash plug-in. If they re-launch, it often works fine the second time.

Is it possible that not all of the initialisation has completed? (despite me calling this on the UI thread)

I'm using multi_threaded_message_loop, and this is CEF 1.1180.832.
ScottKevill
Techie
 
Posts: 16
Joined: Sun Oct 14, 2012 10:34 pm

Re: CEF1: Possible race condition with CefGetWebPluginInfo?

Postby ryanmolden » Thu Jan 03, 2013 10:08 pm

Is it possible that not all of the initialisation has completed? (despite me calling this on the UI thread)


If you are using a multi-threaded message loop you are on YOUR app's UI thread, but not the CEF UI thread. I haven't look through the code, but I suspect in this case CefInitialize is kicking off said 'other (UI) thread' and that thread is doing all the bootstrapping work. In this case I would suspect that CefInitialize may return rather quickly and you would then have a race between the initialization work being completed and your posted UI task being run on CEF's UI thread. If the initialization is multi-phased and event driven (as I suspect it would be) then it seems highly likely your posted message will be handled before all of that completes.

Have you looked into something like implementing CefLifeSpanHandler and doing the check in OnAfterCreated? Intuitively it seems by the time the CefBrowser object is created that it should know about things like availability of Flash, etc..., though that is just idle speculation.

Ryan
ryanmolden
Techie
 
Posts: 12
Joined: Mon Dec 17, 2012 2:56 pm

Re: CEF1: Possible race condition with CefGetWebPluginInfo?

Postby ScottKevill » Sat Jan 05, 2013 2:32 pm

Yes, I'm aware of the differences between the main thread and the UI thread for multi-threaded message, otherwise I wouldn't need to post to the UI thread. My assumption was that posting the task to the UI thread should have it serialised after any other initialisation tasks that CefInitialize() queued up.

I have no doubt that the plug-in info would be ready by the time a browser is created, but this is global state and CefGetWebPluginInfo is a global function so I really shouldn't need to do that "just to make sure."

If CefInitialize() doesn't queue up serial, (UI thread) blocking tasks and instead relies on notifications from other threads, then "must be called on the UI thread" is necessary but not sufficient for CefGetWebPluginInfo(). In which case, there needs to be some reliable method to determine when this is ready, such as OnAfterWebPluginsScan().
ScottKevill
Techie
 
Posts: 16
Joined: Sun Oct 14, 2012 10:34 pm

Re: CEF1: Possible race condition with CefGetWebPluginInfo?

Postby magreenblatt » Sat Jan 05, 2013 3:27 pm

The loading of plugin information is initiated by and seems to be synchronous with the call to CefGetWebPluginInfo. The code uses a number of techniques to discover the flash plugin library (registry, default locations, etc. See plugin_list_win.cc in Chromium for details). It would be interesting to know if in your case Chromium is failing to find any plugins or just failing to find the flash plugin. Perhaps use the version of CefGetWebPluginInfo that returns a list and log the results.
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 183 guests