java.lang.NullPointerException: at org.mozilla.gecko.GeckoApp$16.run(GeckoApp.java)

RESOLVED FIXED in Firefox 15

Status

()

Firefox for Android
General
--
critical
RESOLVED FIXED
6 years ago
6 years ago

People

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

Tracking

({crash})

14 Branch
Firefox 15
ARM
Android
crash
Points:
---

Firefox Tracking Flags

(firefox14 affected)

Details

(Whiteboard: [native-crash][startupcrash][14.0b2], crash signature)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
There are 4 crashes from the same user in 14.0b2: bp-6ede2ce3-3daf-45e8-bc22-8bf0c2120519.

java.lang.NullPointerException
	at org.mozilla.gecko.GeckoApp$16.run(GeckoApp.java:993)
	at android.os.Handler.handleCallback(Handler.java:605)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4581)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
	at dalvik.system.NativeStart.main(Native Method)

More reports at:
https://crash-stats.mozilla.com/report/list?signature=java.lang.NullPointerException%3A+at+org.mozilla.gecko.GeckoApp%2416.run%28GeckoApp.java%29

Comment 1

6 years ago
Looks like this is from this line:
http://hg.mozilla.org/releases/mozilla-aurora/file/ecb8c62dac5a/mobile/android/base/GeckoApp.java#l993

sMenu is guaranteed to not be null, so it seems like the only explanation is that sMenu.findItem(R.id.char_encoding) is null, but I'm also not sure how that's possible.
(Assignee)

Comment 2

6 years ago
Maybe the menu was closed by the time the Runnable was executed. We should move the null check inside the Runnable.

We make a similar mistake in other places, such as:

if (Tabs.getInstance().isSelectedTab(tab)) {
    mMainHandler.post(new Runnable() {
        public void run() {
            mLayerController.getView().getTouchEventHandler().setWaitForTouchListeners(true);
        }
    });
}

and

if (mAboutHomeContent != null) {
    mMainHandler.post(new Runnable() {
        public void run() {
            mAboutHomeContent.setLastTabsVisibility(false);
        }
    });
}
(Assignee)

Comment 3

6 years ago
Created attachment 626252 [details] [diff] [review]
patch

Move checks inside Runnables.
Assignee: nobody → bnicholson
Attachment #626252 - Flags: review?(mark.finkle)
Comment on attachment 626252 [details] [diff] [review]
patch

                public void run() {
>+                        if (sMenu != null) {
>                             sMenu.findItem(R.id.char_encoding).setVisible(visible);
>                         }

{} not needed for a one-liner

>+                    public void run() {
>+                        if (Tabs.getInstance().isSelectedTab(tab)) {
>                             mLayerController.getView().getTouchEventHandler().setWaitForTouchListeners(true);
>                         }

same

>+                    public void run() {
>+                        if (mAboutHomeContent != null) {
>                             mAboutHomeContent.setLastTabsVisibility(false);
>                         }

same

Having the if checks outside the runnable, as well as inside, save us from creating a runnable sometimes. But this is probably not as useful as making sure the checks are done _inside_ the runnable.
Attachment #626252 - Flags: review?(mark.finkle) → review+

Comment 6

6 years ago
https://hg.mozilla.org/mozilla-central/rev/2ef3e8cef102
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 15
(Reporter)

Updated

6 years ago
status-firefox14: --- → affected
You need to log in before you can comment on or make changes to this bug.