Updates:
Status: Started
Cc:
apatr...@chromium.org
Comment #11 on issue 133885 by
k...@chromium.org: GPU memory leak on the mac
with Flash
http://code.google.com/p/chromium/issues/detail?id=133885
Thanks to help from jbauman, thakis and apatrick, did extensive
experimentation today and now know one code change which avoids the
resource leak.
I built Firefox Aurora from sources in order to be able to compare its
behavior to Chrome. Setting breakpoints in CGLCreateContext and
CGLDestroyContext indicated that the same OpenGL context leak existed in
Firefox! However, jbauman pointed out that
CGLRetainContext/CGLReleaseContext might be being used, which was an
excellent point, and in fact those are used (by Core Animation) to maintain
its contexts. However, many calls to these functions are made when
navigating to and away from a YouTube video; it would be tedious to figure
out which contexts they're being called against.
With help from thakis I tried to instrument the dealloc call on the class
of the CALayer returned by the plugin, using the trick in
chrome/browser/ui/cocoa/
custom_frame_view.mm, in order to see if the layer
was being deallocated in one browser but not the other. The reference
counts looked identical in the two browsers. However, this instrumentation
didn't work well. We saw various CALayers being deallocated at various
points, including during plugin resizing in Chrome, but not the root one.
There is one obvious difference in behavior between Chrome's and Firefox's
plugin hosts. Firefox forcibly invalidates and deletes all NPObject
instances vended by the plugin instance immediately after calling
NPP_Destroy. Chrome only does this for the plugin's scriptable object, but
not other objects. See Issue 119414 and
https://chromiumcodereview.appspot.com/9979022 . It turns out that when
visiting a YouTube page and then navigating away from it, Firefox forcibly
deletes three NPObjects. It didn't look simple to implement Firefox's
behavior in Chrome, but I tried commenting out the code which does the
cleanup in Firefox. This didn't cause the resource leak to start happening
in Firefox, indicating the behavioral difference was coming from elsewhere.
After a few failed experiments I tried -- on recommendation from thakis
based on feedback from jbauman -- manually calling release against the
CALayer instance vended by the plugin. Releasing it twice after the plugin
instance is destroyed fixes the GPU resource leak, apparently without
introducing plugin process crashes.
Tomorrow I'll track down exactly where in the Firefox code that CALayer is
being released. There must be a difference between Firefox's management of
this layer's lifetime and Chrome's. Regardless, it seems clear that Flash
is not following the specification in
https://wiki.mozilla.org/NPAPI:CoreAnimationDrawingModel for the management
of this layer's lifetime.