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 752922 ad9f6cf50e5d1859c6056094f0d3b1dc96ec95cb
parent 752921 8ffd7252f4b9e8505982bbb21bf873bf91c129c4
child 752923 032ad85ded1f4a4903ffc33aed865f5c968db5d1
push id98429
push usermak77@bonardo.net
push dateFri, 09 Feb 2018 10:14:12 +0000
reviewersrbarker
bugs1435499
milestone60.0a1
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);