Closed Bug 727454 Opened 8 years ago Closed 8 years ago

android.view.InflateException: Binary XML file line #28: Error inflating class <unknown>

Categories

(Firefox for Android :: General, defect)

13 Branch
ARM
Android
defect
Not set

Tracking

()

VERIFIED FIXED
Firefox 14
Tracking Status
firefox13 --- verified
firefox14 --- verified

People

(Reporter: aaronmt, Assigned: sriram)

Details

(Keywords: regression)

Attachments

(1 file)

I/ActivityManager(  197): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.mozilla.fennec/.App} from pid 473
W/WindowManager(  197): ActivityRecord{41d0e838 org.mozilla.fennec/.App} failed creating starting window
W/WindowManager(  197): android.view.InflateException: Binary XML file line #28: Error inflating class <unknown>
W/WindowManager(  197): 	at android.view.LayoutInflater.createView(LayoutInflater.java:606)
W/WindowManager(  197): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
W/WindowManager(  197): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
W/WindowManager(  197): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
W/WindowManager(  197): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
W/WindowManager(  197): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
W/WindowManager(  197): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
W/WindowManager(  197): 	at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2685)
W/WindowManager(  197): 	at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2745)
W/WindowManager(  197): 	at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1534)
W/WindowManager(  197): 	at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:1264)
W/WindowManager(  197): 	at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:6488)
W/WindowManager(  197): 	at android.os.Handler.dispatchMessage(Handler.java:99)
W/WindowManager(  197): 	at android.os.Looper.loop(Looper.java:137)
W/WindowManager(  197): 	at com.android.server.wm.WindowManagerService$WMThread.run(WindowManagerService.java:690)
W/WindowManager(  197): Caused by: java.lang.reflect.InvocationTargetException
W/WindowManager(  197): 	at java.lang.reflect.Constructor.constructNative(Native Method)
W/WindowManager(  197): 	at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
W/WindowManager(  197): 	at android.view.LayoutInflater.createView(LayoutInflater.java:586)
W/WindowManager(  197): 	... 14 more
W/WindowManager(  197): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class org.mozilla.gecko.BrowserToolbar
W/WindowManager(  197): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
W/WindowManager(  197): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
W/WindowManager(  197): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
W/WindowManager(  197): 	at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:236)
W/WindowManager(  197): 	... 17 more
W/WindowManager(  197): Caused by: java.lang.ClassNotFoundException: org.mozilla.gecko.BrowserToolbar
W/WindowManager(  197): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
W/WindowManager(  197): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/WindowManager(  197): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/WindowManager(  197): 	at android.view.LayoutInflater.createView(LayoutInflater.java:552)
W/WindowManager(  197): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
W/WindowManager(  197): 	... 20 more

I get this on cold start-up.

--
Samsung Galaxy Nexus (Android 4.0.2)
Nightly (02/15)
Mozilla/5.0 (Android; Mobile; rv:13.0a1) Gecko/13.0a1 Firefox/13.0a1
Keywords: regression
Is it
Is it a crash?
Nope.
Might be a recent regression from the startup fixes.
Assignee: nobody → sriram
This is because of recent changes to load the ActionBar in XML. However, I am not sure why it is crashing. Probably different packages are causing problems with ActionBar. I'm try other ways to solve this -- like using a ViewStub. Nothing has helped me so far.
Sriram, it's not crashing (at least for me).
tracking-fennec: --- → ?
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 727959
The issue here is not related to the other bug.
The stack trace is different for both.

Based on my series of investigations:
1. LayoutInflater tries to load classes defined in android.widget by default, by parsing XML files. If we have a <org.mozilla.gecko.Something> tag, it tries to see if we have set up a Factory (LayoutInflater.Factory) to get a View from it. This is actually helpful for (a) giving the LayoutInflater an instance right away, (b) using <GeckoBrowserToolbar> instead of <org.mozilla.gecko.BrowserToolbar>
We don't set any Factory so far. So, this condition fails. The LayoutInflater tries to find the class based on package and the class name definition, using ClassLoader. This is how all our "custom views" are loaded.

2. However, the factory can be set only in onCreate(). The sad part is, custom view of ActionBar is parsed _before_ activity's onCreate() is called. So, setting a factory can only help for "non ActionBar layout files" -- where we will have a win. Also, ActionBar _might_ use a different LayoutInflater than Activity's (which I should confirm). Hypothetically, in our case, ActionBar fails to load BrowserToolbar. When the activity comes up, the default LayoutInflater uses class-loader to load the BrowserToolbar, where we are saved.

Required Solutions:
1. To avoid this crash, and to bring the UI much-much-much faster, the best way is to uses <LinearLayout> as parent for browser_toolbar.xml. Once the layout is loaded, in activity's onCreate(), we can take the required fields from that layout -- | mBrowserToolbar.intializeFrom(actionBarLayout) |

2. To optimize the "in-content" loading of "custom-views", it's better to have our own Factory to give the LayoutInflater an instance much faster. This factory needs to be set for every activity that uses custom views. "every activity" is a pain -- but, we don't have a choice, as LayoutInflater for each activity is "cloned" from "base context". I tried having the factory at "Application" level, and that didn't help us because of "cloning".

As a part of this bug, I'll move the parent to LinearLayout in browser_toolbar.xml
The optimization part will be landed as a followup.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Attached patch PatchSplinter Review
This uses a <LinearLayout> as parent and hence loads faster.
The UI is right there just when someone taps on the icon.
And finally, we beat Chrome!!! yaaaaayyyy!!!
Attachment #607764 - Flags: review?(mark.finkle)
Comment on attachment 607764 [details] [diff] [review]
Patch


>diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java
>+        LinearLayout actionBar;
>+
>         if (Build.VERSION.SDK_INT >= 11) {

nit: no blank line
Attachment #607764 - Flags: review?(mark.finkle) → review+
Version: unspecified → Firefox 13
https://hg.mozilla.org/mozilla-central/rev/4c5b0c31aa54
Status: REOPENED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → FIXED
Version: Firefox 13 → Firefox 14
Target Milestone: --- → Firefox 14
Version: Firefox 14 → unspecified
Version: unspecified → Firefox 13
Looking trough the logs on a cold start the error from comment 0 is not reproducible anymore on:
Nightly Fennec 15.0a1 (2012-06-04)
Aurora Fennec 14.0a2 (2012-06-04)
Device: HTC Desire Z
OS: Android 2.3.3
Status: RESOLVED → VERIFIED
tracking-fennec: ? → ---
You need to log in before you can comment on or make changes to this bug.