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

RESOLVED FIXED in Firefox 25



Firefox for Android
4 years ago
a year ago


(Reporter: Scoobidiver (away), Assigned: mkajda)


({crash, regression, topcrash})

25 Branch
Firefox 25
crash, regression, topcrash

Firefox Tracking Flags

(firefox24 unaffected, firefox25+ fixed)


(Whiteboard: [native-crash], crash signature)


(1 attachment, 3 obsolete attachments)



4 years ago
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:

Comment 1

4 years ago
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.

Comment 2

4 years ago
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).


4 years ago
Blocks: 887020


4 years ago
Assignee: nobody → michal.kajda
Flags: needinfo?(sriram)

Comment 3

4 years ago
There are 20 crashes in one build.
tracking-fennec: --- → ?
tracking-firefox25: --- → ?
Keywords: topcrash

Comment 4

4 years ago
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.

Comment 5

4 years ago
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."

Comment 6

4 years ago
Created attachment 769480 [details] [diff] [review]
Changed initialization point of mProgressSpinner

Comment 7

4 years ago
Created attachment 769481 [details] [diff] [review]
Return from method if mProgressSpinner is null

Comment 8

4 years ago
I added to patches with different solutions and hope any of them is OK ;)

Comment 9

4 years ago
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.

Comment 11

4 years ago
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)

Comment 14

4 years ago
Created attachment 769839 [details] [diff] [review]
Initialization point of mProgressSpinner changed and made consistent with other drawables.

@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+

Comment 16

4 years ago
Created attachment 769850 [details] [diff] [review]
Initializes mProgressSpinner in the constructor of BrowserToolbar

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)


4 years ago
tracking-firefox25: ? → +
Attachment #769850 - Flags: review?(sriram) → review+


4 years ago
status-firefox25: affected → fixed
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 25
tracking-fennec: ? → ---
You need to log in before you can comment on or make changes to this bug.