Bug 1476424 Crash in android.os.TransactionTooLargeException: data parcel size 3124056 bytes at android.os.BinderProxy.transactNative(Native Method) r?sdaswani draft
authorAndrei Lazar <andrei.a.lazar@softvision.ro>
Mon, 23 Jul 2018 13:08:49 +0300
changeset 821450 fd178a98784aaf3d4840c3af429169857d1a5fcc
parent 819645 8dab948a10f073a46f13f55f94d1f6514c7360ac
push id117097
push userbmo:andrei.a.lazar@softvision.ro
push dateMon, 23 Jul 2018 10:13:05 +0000
reviewerssdaswani
bugs1476424, 3124056
milestone63.0a1
Bug 1476424 Crash in android.os.TransactionTooLargeException: data parcel size 3124056 bytes at android.os.BinderProxy.transactNative(Native Method) r?sdaswani Upon saving the state of onboarding fragments, the bundle can exceed 3MB because of the bitmaps. Therefore, now we pass a resources id instead of passing the full bitmap through the bundle. MozReview-Commit-ID: 9zpXrmolT38
mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPanel.java
mobile/android/base/java/org/mozilla/gecko/firstrun/LocalFirstRunPanelProvider.java
mobile/android/base/java/org/mozilla/gecko/firstrun/PanelConfig.java
mobile/android/base/java/org/mozilla/gecko/mma/LeanplumVariables.java
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
@@ -1,22 +1,19 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.firstrun;
 
 import android.content.Context;
-import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 
-import org.mozilla.gecko.mma.MmaDelegate;
-
 import java.util.LinkedList;
 import java.util.List;
 
 class FirstrunPagerConfig {
     static final String LOGTAG = "FirstrunPagerConfig";
 
     static final String KEY_IMAGE = "panelImage";
     static final String KEY_MESSAGE = "panelMessage";
@@ -49,27 +46,27 @@ class FirstrunPagerConfig {
     }
 
     static class FirstrunPanelConfig {
         private String classname;
         private String title;
         private Bundle args;
 
         FirstrunPanelConfig(String resource, String title) {
-            this(resource, title, null, null, null, true);
+            this(resource, title, -1, null, null, true);
         }
 
-        private FirstrunPanelConfig(String classname, String title, Bitmap image, String message,
+        private FirstrunPanelConfig(String classname, String title, int image, String message,
                                     String subtext, boolean isCustom) {
             this.classname = classname;
             this.title = title;
 
             if (!isCustom) {
                 args = new Bundle();
-                args.putParcelable(KEY_IMAGE, image);
+                args.putInt(KEY_IMAGE, image);
                 args.putString(KEY_MESSAGE, message);
                 args.putString(KEY_SUBTEXT, subtext);
             }
         }
 
         static FirstrunPanelConfig getConfiguredPanel(@NonNull Context context,
                                                       PanelConfig.TYPE wantedPanelConfig,
                                                       final boolean useLocalValues) {
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPanel.java
@@ -1,16 +1,15 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.firstrun;
 
-import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -28,21 +27,21 @@ public class FirstrunPanel extends Fragm
 
     protected boolean showBrowserHint = true;
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
         final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_basepanel_checkable_fragment, container, false);
         final Bundle args = getArguments();
         if (args != null) {
-            final Bitmap image = args.getParcelable(FirstrunPagerConfig.KEY_IMAGE);
+            final int image = args.getInt(FirstrunPagerConfig.KEY_IMAGE);
             final String message = args.getString(FirstrunPagerConfig.KEY_MESSAGE);
             final String subtext = args.getString(FirstrunPagerConfig.KEY_SUBTEXT);
 
-            ((ImageView) root.findViewById(R.id.firstrun_image)).setImageBitmap(image);
+            ((ImageView) root.findViewById(R.id.firstrun_image)).setImageDrawable(getResources().getDrawable(image));
             ((TextView) root.findViewById(R.id.firstrun_text)).setText(message);
             ((TextView) root.findViewById(R.id.firstrun_subtext)).setText(subtext);
         }
 
         root.findViewById(R.id.firstrun_link).setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-next");
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/LocalFirstRunPanelProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/LocalFirstRunPanelProvider.java
@@ -2,46 +2,45 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.firstrun;
 
 import android.content.Context;
 import android.content.res.Resources;
-import android.graphics.BitmapFactory;
 import android.support.annotation.NonNull;
 
 import org.mozilla.gecko.R;
 
 public class LocalFirstRunPanelProvider implements FirstRunPanelConfigProviderStrategy {
     public PanelConfig getPanelConfig(@NonNull Context context, PanelConfig.TYPE type, final boolean useLocalValues) {
         final Resources resources = context.getResources();
         switch (type) {
             case WELCOME:
                 return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
                         resources.getString(R.string.firstrun_urlbar_message),
                         resources.getString(R.string.firstrun_urlbar_subtext),
-                        BitmapFactory.decodeResource(resources, R.drawable.firstrun_welcome));
+                        R.drawable.firstrun_welcome);
             case PRIVACY:
                 return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_privacy),
                         resources.getString(R.string.firstrun_privacy_message),
                         resources.getString(R.string.firstrun_privacy_subtext),
-                        BitmapFactory.decodeResource(resources, R.drawable.firstrun_private));
+                        R.drawable.firstrun_private);
             case CUSTOMIZE:
             case LAST_CUSTOMIZE:
                 return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_customize),
                         resources.getString(R.string.firstrun_customize_message),
                         resources.getString(R.string.firstrun_customize_subtext),
-                        BitmapFactory.decodeResource(resources, R.drawable.firstrun_data));
+                        R.drawable.firstrun_data);
             case SYNC:
                 return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_sync_title),
                         resources.getString(R.string.firstrun_sync_message),
                         resources.getString(R.string.firstrun_sync_subtext),
-                        BitmapFactory.decodeResource(resources, R.drawable.firstrun_sync));
+                        R.drawable.firstrun_sync);
             default:    // This will also be the case for "WELCOME"
                 return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
                         resources.getString(R.string.firstrun_urlbar_message),
                         resources.getString(R.string.firstrun_urlbar_subtext),
-                        BitmapFactory.decodeResource(resources, R.drawable.firstrun_welcome));
+                        R.drawable.firstrun_welcome);
         }
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/PanelConfig.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/PanelConfig.java
@@ -1,33 +1,31 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.firstrun;
 
-import android.graphics.Bitmap;
-
 /**
  * Onboarding screens configuration object.
  */
 public class PanelConfig {
     public enum TYPE {
         WELCOME, PRIVACY, CUSTOMIZE, LAST_CUSTOMIZE, SYNC
     }
 
     private final TYPE type;
     private final boolean useLocalValues;
     private final String title;
     private final String message;
     private final String text;
-    private final Bitmap image;
+    private final int image;
 
-    public PanelConfig(TYPE type, boolean useLocalValues, String title, String message, String text, Bitmap image) {
+    public PanelConfig(TYPE type, boolean useLocalValues, String title, String message, String text, int image) {
         this.type = type;
         this.useLocalValues = useLocalValues;
         this.title = title;
         this.message = message;
         this.text = text;
         this.image = image;
     }
 
@@ -61,12 +59,12 @@ public class PanelConfig {
     public String getMessage() {
         return message;
     }
 
     public String getText() {
         return text;
     }
 
-    public Bitmap getImage() {
+    public int getImage() {
         return image;
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/mma/LeanplumVariables.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/LeanplumVariables.java
@@ -2,18 +2,16 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.mma;
 
 import android.content.Context;
 import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
 import android.support.annotation.DrawableRes;
 import android.support.annotation.NonNull;
 
 import com.leanplum.annotations.Variable;
 
 import org.mozilla.gecko.R;
 
 import java.lang.reflect.Field;
@@ -95,28 +93,25 @@ public class LeanplumVariables {
         customizingDrawableId = R.drawable.firstrun_data;
 
         syncPanelTitle = appResources.getString(R.string.firstrun_sync_title);
         syncPanelMessage = appResources.getString(R.string.firstrun_sync_message);
         syncPanelSubtext = appResources.getString(R.string.firstrun_sync_subtext);
         syncDrawableId = R.drawable.firstrun_sync;
     }
 
-    public static Bitmap getWelcomeImage() {
-        return getBitmapFromMmaVar(welcomeDrawableId);
+    public static int getWelcomeImage() {
+        return welcomeDrawableId;
     }
 
-    public static Bitmap getPrivacyImage() {
-        return getBitmapFromMmaVar(privacyDrawableId);
+    public static int getPrivacyImage() {
+        return privacyDrawableId;
     }
 
-    public static Bitmap getCustomizingImage() {
-        return getBitmapFromMmaVar(customizingDrawableId);
+    public static int getCustomizingImage() {
+        return customizingDrawableId;
     }
 
-    public static Bitmap getSyncImage() {
-        return getBitmapFromMmaVar(syncDrawableId);
+    public static int getSyncImage() {
+        return syncDrawableId;
     }
 
-    private static Bitmap getBitmapFromMmaVar(@DrawableRes final int drawableRes) {
-        return BitmapFactory.decodeResource(appResources, drawableRes);
-    }
 }