Various `NullPointerException`s in production with expo 49

  1. SDK Version: 49
  2. Platform: Android

The problem

We are noticing our app crashing with NullPointerException occasionally in production. It seems to affect <1% of our users, but we are still seeing consistently a few times a day.

Our app uses the expo location and notification modules, and so far the stack traces always are calls to these modules.

Traces

location module:

java.lang.NullPointerException: java.lang.NullPointerException
    at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt)
    at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt:24)
    at expo.modules.kotlin.PromiseKt$toBridgePromise$resolveMethod$1.invoke(Promise.kt:22)
    at expo.modules.kotlin.PromiseKt$toBridgePromise$resolveMethod$1.invoke(Promise.kt:22)
    at expo.modules.kotlin.PromiseKt$toBridgePromise$1.resolve(Promise.kt:29)
    at expo.modules.adapters.react.PromiseWrapper.resolve(PromiseWrapper.java:27)
    at expo.modules.location.LocationHelpers$1.onLocationChanged(LocationHelpers.java:157)
    at expo.modules.location.LocationModule$1.onLocationResult(LocationModule.java:557)
    at com.google.android.gms.internal.location.zzaw.notifyListener(com.google.android.gms:play-services-location@@20.0.0:2)
    at com.google.android.gms.common.api.internal.ListenerHolder.zaa(com.google.android.gms:play-services-base@@18.1.0:2)
    at com.google.android.gms.common.api.internal.zacb.run
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.os.HandlerThread.run(HandlerThread.java:67)

notifications module:

java.lang.NullPointerException: java.lang.NullPointerException
    at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt)
    at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt:24)
    at expo.modules.kotlin.jni.PromiseImpl.reject(PromiseImpl.kt:87)
    at expo.modules.kotlin.PromiseKt$toBridgePromise$1.reject(Promise.kt:41)
    at expo.modules.adapters.react.PromiseWrapper.reject(PromiseWrapper.java:36)
    at expo.modules.notifications.notifications.presentation.ExpoNotificationPresentationModule$4.onReceiveResult(ExpoNotificationPresentationModule.java:98)
    at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:59)
    at android.os.ResultReceiver.send(ResultReceiver.java:93)
    at expo.modules.notifications.service.NotificationsService.handleIntent(NotificationsService.kt:650)
    at expo.modules.notifications.service.NotificationsService$onReceive$1.invoke(NotificationsService.kt:588)
    at expo.modules.notifications.service.NotificationsService$onReceive$1.invoke(NotificationsService.kt:586)
    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
java.lang.NullPointerException: java.lang.NullPointerException
    at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt)
    at expo.modules.kotlin.jni.JavaCallback.invoke(JavaCallback.kt:24)
    at expo.modules.kotlin.jni.PromiseImpl.reject(PromiseImpl.kt:87)
    at expo.modules.kotlin.PromiseKt$toBridgePromise$1.reject(Promise.kt:41)
    at expo.modules.adapters.react.PromiseWrapper.reject(PromiseWrapper.java:36)
    at expo.modules.notifications.tokens.PushTokenModule$1.onComplete(PushTokenModule.java:72)
    at com.google.android.gms.tasks.zzi.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8855)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Other details

  • The error has happened on app launch and some time after the app is in use (this makes sense since we setup the expo-notification handler on startup but use expo-location later on)
  • Only seen on samsung phones so far
  • Seen on multiple android version (10, 11, 13)
  • Sentry does not seem to be able to provide any javascript stack trace when these crashes occur
  • We have found some expo issues that kind of look similar (#23382, #17426) but nothing that really seems to match up with our problem

We are having problems consistently reproducing the problem, but here is a repo with the minimum requirements to trigger the problem: GitHub - patidarsarvesh/ExpoNullPointerIssue.

If you have any tips on how we should proceed they would be very appreciated. We are having problems debugging since we don’t write any native code ourselves.

An update (since I’m not sure how to close this on discourse):

We discovered the crashes come from calling reloadAsync from expo-updates. We have opened an issue with a reproduction on the expo github repo.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.