Comment 12 for bug 1076350

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

https://code.launchpad.net/~chrisccoulson/unity-firefox-extension/lp1076350 fixes it here. It does 2 things:

1) Keys UnityObject in a weak map with an object that's tied to the inner window (I don't think it's possible to get the inner window from an outer window), so each new page gets a new object.

2) Doesn't disconnect from "pagehide" unless the window is being destroyed (using the "dom-window-destroyed" notification). This fixes another issue similar to this one where navigating back to a page that previously used the Unity API and which gets recovered from the bfcache could cause a crash when the tab is closed, because its pagehide handler would have already been disconnected.

The behaviour of this API is pretty broken compared to any other DOM API though wrt page navigations though. When you navigate away from a page and it gets inserted in to the bfcache, its state should be frozen until it is recovered from the cache later on (unless it gets removed from the bfcache, in which case the page will be reloaded in a new inner window). However, the Unity API doesn't freeze the state - it actually destroys the context which means a page that is recovered from the bfcache has to reinitialize everything again.

I'm not sure if the changes I've done break anything else though. This whole thing seems really fragile.