Closed Bug 888641 Opened 9 years ago Closed 9 years ago

java.lang.NullPointerException: at org.mozilla.gecko.BrowserToolbar.setProgressVisibility(


(Firefox for Android Graveyard :: General, defect)

25 Branch
Not set


(firefox24 unaffected, firefox25+ fixed)

Firefox 25
Tracking Status
firefox24 --- unaffected
firefox25 + fixed


(Reporter: scoobidiver, Assigned: mkajda)



(Keywords: crash, regression, topcrash, Whiteboard: [native-crash])

Crash Data


(1 file, 3 obsolete files)

It has been hit by three users in 25.0a1/2013029. The regression range is:
I think it's a regression from bug 887020.

Here is a crash report: bp-132521ef-622b-4264-bb27-115762130629.

	at org.mozilla.gecko.BrowserToolbar.setProgressVisibility(
	at org.mozilla.gecko.BrowserToolbar.onTabChanged(
	at org.mozilla.gecko.Tabs$
	at android.os.Handler.handleCallback(
	at android.os.Handler.dispatchMessage(
	at android.os.Looper.loop(
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(
	at dalvik.system.NativeStart.main(Native Method)

More reports at:
Hi All,

May I take this bug and start working on it?
I am completely new here, but would like to start contributing.
If someone could be my mentor, it would be great.

I looked into this a bit and it seems that it crashes because mProgressSpinner is null when mProgressSpinner.start(); gets called.

mProgressSpinner is instantiated in onAttachedToWindow callback (@ line 347 in which in turn might be called later than onTabChanged.
The only what is guaranteed according to Android docs that attachedToWindow would be invoked before onDraw, but this could happen at any time.
So I suspect race condition occurred.

I haven't reproduced this though.
If anyone had testing scenario for it I would appreciate it.

Please let me know your thoughts and if I can go for it.
Previously there was 'public void from(RelativeLayout layout)' method in BrowserToolbar class and was replaced (more or less) by 'public void onAttachedToWindow()' callback.

As mentioned in previous comment 'onAttachedToWindow' is called asynchronously before 'onDraw' gets called. The 'from' method was called synchronously in BrowserApp's 'onCreate' callback, so mProgressSpinner had valid value when BrowserApp was created.

All these changes where introduced by this revision when working on (as Scoobidiver suspected).
Blocks: 887020
Assignee: nobody → michal.kajda
Flags: needinfo?(sriram)
There are 20 crashes in one build.
tracking-fennec: --- → ?
Keywords: topcrash
The crash is caused by Tabs' notifyListeners method which is run in UI thread and because it is current thread (main thread) it is called immediately. Apparently one of the listeners is BrowserToolbar which has not been yet attached to window, so its mProgressSpinner is equal to null.

I still haven't reproduced it on my Nexus 4.

How can I debug Fennec using DDMS? I tried this but description or me are missing something.

I think that moving 
ProgressSpinner = (AnimationDrawable) getResources().getDrawable(R.drawable.progress_spinner); from onAttachedToWindow method to constructor of BrowserToolbar is the most straightforward solution.

The question is if it is sufficient.
Here are some comments from recent crash report (translated from Russian to English by google translator)

"If you attempt to use the built-in search Yandex, your browser has fallen."

"When you try to open an official project page CyanogenMod, your browser has fallen."
I added to patches with different solutions and hope any of them is OK ;)
It's worth to look into all crash reports :)
Some of them contain more detailed stack trace:
maybe it differs because activity was resuming not launching.
On Samsung Galaxy Nexus (Android 4.1.1) using Nightly 25.0a1 (2013-06-30) the app crashes with this crash signature.
1. go to a website( for example
2. go to
The app crashes.
Thanks for STR Teodora, but still wasn't able to reproduce.
I tried nigthly builds and built locally from repo as well. No luck.

Are you using tabs sync between PC and mobile devices?
Comment on attachment 769480 [details] [diff] [review]
Changed initialization point of mProgressSpinner

Review of attachment 769480 [details] [diff] [review]:

Sounds good to me.
Attachment #769480 - Flags: review+
(In reply to Michal Kajda from comment #7)
> Created attachment 769481 [details] [diff] [review]
> Return from method if mProgressSpinner is null

This might not be needed.
Flags: needinfo?(sriram)
@Sriram: Thank you for review of previous patch. I prepared another one which as I realized that this one would be more consistent with initialization of other drawables. It uses stored resources reference instead of calling getResources() method again.
Attachment #769480 - Attachment is obsolete: true
Attachment #769481 - Attachment is obsolete: true
Attachment #769839 - Flags: review?(sriram)
Comment on attachment 769839 [details] [diff] [review]
Initialization point of mProgressSpinner changed and made consistent with other drawables.

Could you please move the initialization a bit below?
May be after

r+ with that.
Attachment #769839 - Flags: review?(sriram) → review+
In case of 'r+': Could anyone push it to the try server please? I don't have permissions as I'm a 'new starter' ;)
Attachment #769839 - Attachment is obsolete: true
Attachment #769850 - Flags: review?(sriram)
Attachment #769850 - Flags: review?(sriram) → review+
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 25
tracking-fennec: ? → ---
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.