~webapps/unity-chromium-extension/14.04

« back to all changes in this revision

Viewing changes to chromium-extension/browser.js

  • Committer: Tarmac
  • Author(s): Alexandre Abreu
  • Date: 2013-07-08 15:04:14 UTC
  • mfrom: (224.1.1 fix-chromium-28-support)
  • Revision ID: tarmac-20130708150414-2krskytsa61xd6v7
Tags: BRANCH_13_04
[Impact]

Workaround for an issue with Chromium 27 and 28 and Webapps. Webapps stopped working altogether with those chromium versions. What happened is that any javascript callback function that was called (whatever the stage) from chromium's internal could not access the NPAPI plugin variable (_uwa) that is a javascript object that is a bridge to the WebApps NPAPI plugin. Accessing the variable throws with an exception "NPObject has been deleted" (which is not the case).

The workaround rebinds the variable for every callback to the plugin node.

TECHNICAL DETAILS:
-----------------

There has been some changes recently in chromium 27+ around the v8 bindings' templates separated by world type (either page world or content script private world). Although I am not sure, it seemed to have an impact somewhere in the lookup location for V8NPObject v8 binding variables.

The "NPOBJect has been deleted" exception first occurs when webapps callback in the context_prepare() callback (from a native NPAPI function) that tries to call the plugin using _uwa. The variable is just closed over in the callback but is being looked up in the v8 binding for NPAPI (npObjectInvokeImpl() in WebCore/bindings/v8/V8NPObject.cpp) in the wrong World (page world instead of content script world).

The V8NPObject binding for the NPAPI plugin is apparently created properly (tagged w/ the proper world id) but somewhere along the line (copying?) something goes wrong.

[Test Case]

1. install the unity-chromium-extension,
2. open chromium 28 and make sure that the extension is properly detected (chrome://extensions),
3. go to e.g. facebook.com or bbc.co.uk./news,
4. make sure that a launcher icon appears and the webapps integrates (notifications for bbc and messaging menu for facebook),

[Regression Potential]

None since the fix is strictly confined in the webapps extension and webapps are currently broken.

Approved by PS Jenkins bot, Víctor R. Ruiz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
       logger ("Service object created: " + service);
179
179
 
180
180
       // global plugin initialization
181
 
       api = UnityGlobalPropertyInitializer.makeCallback (plugin, service, logger)(aWindow);
 
181
       // FIXME: there seem to be an issue that started w/ chromium 27+
 
182
       //  where NPobnject v8 bindings are looked up in the wrong
 
183
       //  JS world under some circumstances.
 
184
       api = UnityGlobalPropertyInitializer.makeCallback (
 
185
           function() {
 
186
               return document.getElementById ("unityChromiumExtensionId");
 
187
           },
 
188
           service,
 
189
           logger)(aWindow);
182
190
     }
183
191
   }
184
192