Closed Bug 746938 Opened 9 years ago Closed 9 years ago

java.lang.NullPointerException: at org.mozilla.gecko.GeckoNetworkManager.getNetworkType(GeckoNetworkManager.java)

Categories

(Firefox for Android Graveyard :: General, defect)

ARM
Android
defect
Not set
critical

Tracking

(firefox14 affected, firefox15 affected, blocking-fennec1.0 -)

RESOLVED FIXED
Firefox 16
Tracking Status
firefox14 --- affected
firefox15 --- affected
blocking-fennec1.0 --- -

People

(Reporter: scoobidiver, Assigned: gbrown)

References

Details

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

Crash Data

Attachments

(2 files, 2 obsolete files)

There are four crashes so far, the latest one in 14.0a1/20120414: bp-9a3a7822-e6b4-4a91-b084-0e82b2120419.

java.lang.NullPointerException
	at org.mozilla.gecko.GeckoNetworkManager.getNetworkType(GeckoNetworkManager.java:226)
	at org.mozilla.gecko.GeckoNetworkManager.updateNetworkType(GeckoNetworkManager.java:183)
	at org.mozilla.gecko.GeckoNetworkManager.start(GeckoNetworkManager.java:158)
	at org.mozilla.gecko.GeckoApp.onApplicationResume(GeckoApp.java:2147)
	at org.mozilla.gecko.GeckoApplication.onActivityResume(GeckoApplication.java:55)
	at org.mozilla.gecko.GeckoActivity.onResume(GeckoActivity.java:33)
	at org.mozilla.gecko.GeckoApp.onResume(GeckoApp.java:1987)
	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
	at android.app.Activity.performResume(Activity.java:4539)
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1173)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4424)
	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.GeckoNetworkManager.getNetworkType%28GeckoNetworkManager.java%29
I do not understand what is going wrong here, but we can be more careful about checking for null in getNetworkType.
Assignee: nobody → gbrown
Attachment #625688 - Flags: review?(mounir)
Comment on attachment 625688 [details] [diff] [review]
check for null returns from system calls in getNetworkType

Review of attachment 625688 [details] [diff] [review]:
-----------------------------------------------------------------

::: embedding/android/GeckoNetworkManager.java
@@ +193,5 @@
>  
> +    NetworkInfo ni = cm.getActiveNetworkInfo();
> +
> +    if (ni == null) {
> +      Log.w("GeckoNetworkManager", "Could not get network info");

No need to warn: this is expected when offline IIRC.
Attachment #625688 - Flags: review?(mounir) → review+
Extra warning removed as per review comment.

r=mounir carried.
Attachment #625688 - Attachment is obsolete: true
Attachment #625702 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/9463528f5c09
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
It's #111 top crasher in 14.0b3.
blocking-fennec1.0: --- → ?
It is marked as fixed in Firefox 15 so it isn't surprising to be still visible in Firefox 14, right?
blocking-fennec1.0: ? → -
There are still crashes in 15.0a2.
(In reply to Scoobidiver from comment #10)
> There are still crashes in 15.0a2.

Oh no -- I patched the wrong file!! 

I updated embedding/android/GeckoNetworkManager.java instead of mobile/android/base/GeckoNetworkManager.java.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Same as the previously landed patch, but applied to the native Fennec version of GeckoNetworkManager.
Attachment #625702 - Attachment is obsolete: true
Attachment #634999 - Flags: review?(mounir)
Attachment #625702 - Attachment is obsolete: false
Comment on attachment 634999 [details] [diff] [review]
check for null returns from system calls in getNetworkType - native!

Review of attachment 634999 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the changes listed below.

::: mobile/android/base/GeckoNetworkManager.java
@@ +187,5 @@
>      ConnectivityManager cm =
>        (ConnectivityManager)GeckoApp.mAppContext.getSystemService(Context.CONNECTIVITY_SERVICE);
>  
> +    if (cm == null) {
> +      Log.w("GeckoNetworkManager", "Could not access Connectivity service");

According to the docs [1], the value returned is "The service or null if the name does not exist.". So, I would suggest to switch to an error (because we expect it to exist, right?) and update the message accordingly.

[1] http://developer.android.com/reference/android/content/Context.html#getSystemService(java.lang.String)

@@ +192,5 @@
>        return NetworkType.NETWORK_NONE;
>      }
>  
> +    NetworkInfo ni = cm.getActiveNetworkInfo();
> +

nit: Could you remove that empty line?

@@ +215,5 @@
>      TelephonyManager tm =
>        (TelephonyManager)GeckoApp.mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
>  
> +    if (tm == null) {
> +      Log.w("GeckoNetworkManager", "Could not access Telephony service");

Same as above: should probably be an error and the message should be updated.
Attachment #634999 - Flags: review?(mounir) → review+
Updated for review comments - thanks! r=mounir
Attachment #634999 - Attachment is obsolete: true
Attachment #635374 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/8ec957ae5ffd
Status: REOPENED → RESOLVED
Closed: 9 years ago9 years ago
Resolution: --- → FIXED
Target Milestone: Firefox 15 → Firefox 16
Duplicate of this bug: 735096
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.