Multiple ppapi OpenGL plugins per page

288 views
Skip to first unread message

simon....@gmail.com

unread,
Jul 20, 2015, 5:00:12 AM7/20/15
to peppe...@chromium.org
Hello,

I am using the following example ppapi plugin that renders a spinning cube with openGL https://chromium.googlesource.com/chromium/src/ppapi/+/master/examples/gles2_spinning_cube.

I am able to embed this in a webpage running in Chrome and it all works fine as expected  :D  The code for my html page is identical to here: https://chromium.googlesource.com/chromium/src/ppapi/+/master/examples/gles2_spinning_cube/gles2_spinning_cube.html

However, if I add another embed html element to load the same plugin twice on the same page, only the second embed shows the spinning cube.  The first embed renders a single frame before stopping.  

<embed id="plugin" type="application/x-ppapi-example-gles2-spinning-cube" width="800" height="600"/>
<embed id="plugin2" type="application/x-ppapi-example-gles2-spinning-cube" width="800" height="600"/>


Does Chrome support multiple ppapi plugins on the same web page?  If this should be working fine, then can someone help me identify why this is happening / check if they can reproduce? Fwiw, I am on Ubuntu and I will shortly try on Windows/Mac to compare.  

I am using:
--register-pepper-plugin
so really nothing fancy.  

I figured explaining this not working with the ppapi example code was best here as I don't have to post custom code.  Any more questions please let me know :)

Many thanks,
Simon


p.s. also raised here:

David Michael

unread,
Jul 21, 2015, 11:36:08 AM7/21/15
to simon....@gmail.com, peppe...@chromium.org
That should be possible to do. Most likely the example C++ code isn't written to allow for two PP_Instances (but I haven't looked in a while). Since you're running with "--register-pepper-plugins" instead of using NaCl, loading the plugin twice is going to cause it to use two PP_Instances (or pp::Instance for C++) in the same process. The example code probably assumes one PP_Instance/pp::Instance.

Note that we usually discourage "--register-pepper-plugins" except for debugging/testing, because you can't ship a plugin to Chrome users that way. If you were using NaCl/PNaCl instead, the example would probably work fine because each <embed> on the page would get its own separate process.

If it turns out that there really is a problem with using the OpenGL APIs in more than one <embed> on the page, then you probably should file a bug at crbug.com/new

HTH
-Dave

To unsubscribe from this group and stop receiving emails from it, send an email to pepper-dev+...@chromium.org.

Josh Horwich

unread,
Jul 21, 2015, 4:49:25 PM7/21/15
to David Michael, simon....@gmail.com, peppe...@chromium.org
I believe the problem is that the example code only calls glSetCurrentContextPPAPI in DemoInstance::InitGL. If I call glSetCurrentContextPPAPI in each of the Paint calls, the cube spins in each of the two plugin instances. I'm testing on Ubuntu as well, but suspect this would behave similarly across platforms.

Since the two instances are sharing a process, the g_current_context value in src/ppapi/lib/gl/gles2/gl2ext_ppapi.c is likely staying with whatever plugin's DemoInstance::InitGL finishes last, hence the other one never updates. Note that it's non-deterministic/racy - without my fix, if I reload the page sometimes the first cube spins, sometimes the second.

Cheers,
- Josh

Simon Tolham

unread,
Jul 22, 2015, 5:35:14 AM7/22/15
to Josh Horwich, David Michael, peppe...@chromium.org
Thank you David and Josh.

You're absolutely right. Making that change shows multiple spinning cubes on the page :)  I'm delighted.

Thanks again,
Simon
Reply all
Reply to author
Forward
0 new messages