Bug 1435499 - Guard against OOM when getting toolbar pixels; r=rbarker
authorJim Chen <nchen@mozilla.com>
Thu, 08 Feb 2018 13:23:35 -0500
changeset 403039 ad9f6cf50e5d1859c6056094f0d3b1dc96ec95cb
parent 403038 8ffd7252f4b9e8505982bbb21bf873bf91c129c4
child 403040 032ad85ded1f4a4903ffc33aed865f5c968db5d1
push id33410
push usertoros@mozilla.com
push dateFri, 09 Feb 2018 10:00:41 +0000
treeherdermozilla-central@dfd0afe71bb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarker
bugs1435499
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1435499 - Guard against OOM when getting toolbar pixels; r=rbarker Guard against OOM errors when getting toolbar pixels, and send a failure message back to compositor when OOM happens. MozReview-Commit-ID: FooZlE979DD
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/DynamicToolbarAnimator.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/DynamicToolbarAnimator.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/DynamicToolbarAnimator.java
@@ -158,25 +158,27 @@ public final class DynamicToolbarAnimato
                 // Send updated toolbar image to compositor.
                 final Bitmap bm = mToolbarChromeProxy.getBitmapOfToolbarChrome();
                 if (bm == null) {
                     mCompositor.sendToolbarAnimatorMessage(
                             LayerSession.TOOLBAR_SNAPSHOT_FAILED);
                     break;
                 }
 
-                final int width = bm.getWidth();
-                final int height = bm.getHeight();
-                final int[] pixels = new int[bm.getByteCount() / 4];
                 try {
+                    final int width = bm.getWidth();
+                    final int height = bm.getHeight();
+                    final int[] pixels = new int[bm.getByteCount() / 4];
                     bm.getPixels(pixels, /* offset */ 0, /* stride */ width,
                                  /* x */ 0, /* y */ 0, width, height);
                     mCompositor.sendToolbarPixelsToCompositor(width, height, pixels);
-                } catch (final Exception e) {
+                } catch (final Throwable e) {
                     Log.e(LOGTAG, "Cannot get toolbar pixels", e);
+                    mCompositor.sendToolbarAnimatorMessage(
+                            LayerSession.TOOLBAR_SNAPSHOT_FAILED);
                 }
                 break;
             }
 
             case LayerSession.STATIC_TOOLBAR_READY: {
                 // Hide toolbar and send TOOLBAR_HIDDEN message to compositor
                 mToolbarChromeProxy.toggleToolbarChrome(false);
                 mCompositor.sendToolbarAnimatorMessage(LayerSession.TOOLBAR_HIDDEN);