gecko-dev/mobile
Markus Stange a2b3d3f84d Bug 1655580 - Stop leaking surfaces that were captured with RequestScreenPixels. r=geckoview-reviewers,agi
FlipScreenPixels was heap-allocating and leaking a ScopedMap object, which kept
the surface alive.

Instead, we want to keep the surface alive just long enough to copy its data
into a Java Bitmap object. This copy needs to be done on the C++ side so that
we're sure that it happens while the surface data exists. After that, the Java
code can hold on to the resulting Bitmap object as long as it wants, since the
Bitmap then owns its own data.

The ScreenshotBuilder GeckoView API allows users to specify the bitmap object
that will be used. So rather than creating a new Bitmap object in the C++ code,
we pass the target bitmap into the C++ code that performs the copy.

As a drive-by fix, this patch eliminates another copy at the start of
FlipScreenPixels by replacing a call to `gfx::CreateDataSourceSurfaceFromData`
(which copies) with a call to `gfx::Factory::CreateWrappingDataSourceSurface`
(which doesn't copy).
It would be nice if we could eliminate another copy here, by performing the flip
during the copy into the Bitmap object. But I don't think there's a way to do
that. Also, for optimal performance, we probably want to get an AHardwareBuffer
object from the compositor and wrap that into a Bitmap.

Furthermore, the patch adds a check that makes sure the draw target was created
successfully before accessing it (throwing an exception if not).

Differential Revision: https://phabricator.services.mozilla.com/D85490
2020-07-31 23:03:50 +00:00
..
android Bug 1655580 - Stop leaking surfaces that were captured with RequestScreenPixels. r=geckoview-reviewers,agi 2020-07-31 23:03:50 +00:00
locales Bug 1607092 - Add new quote from Book of Mozilla for GeckoView r=geckoview-reviewers,Pike,agi 2020-07-07 02:22:07 +00:00
.eslintrc.js Bug 1632922 - use const instead of let - manual fixes. r=snorp 2020-04-24 21:53:19 +00:00