Skip to content

Android crashes when app goes to background mode (e.g. with Google Sign In) #5449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mattproch opened this issue Apr 25, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@mattproch
Copy link

mattproch commented Apr 25, 2025

Summary

Hey, I have an Expo app that both uses this library for maps and Google Sign In.

If the map is initialized in one tab, then a user goes to a second tab and presses Sign In With Google, the app crashes.

Reproducible sample code

import { GoogleSignin, statusCodes } from '@react-native-google-signin/google-signin';

await GoogleSignin.hasPlayServices();
await GoogleSignin.signOut();
const response = await GoogleSignin.signIn();

Steps to reproduce

If the map is initialized in one tab, then a user goes to a second tab and presses Sign In With Google, the app crashes with the following error. I don't think the tab navigation is necessary. In my opinion, it's just a problem with the app going into some kind of a background mode because of the Google Sign as the error starts in com.rnmaps.maps.MapView.onPause

Expected result

The app not crashing.

Actual result

App crashing with

Exception java.lang.RuntimeException: Unable to pause activity {com.datart.production/com.datart.production.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bp.w()' on a null object reference
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5689)
  at android.app.ActivityThread.performPauseActivity (ActivityThread.java:5640)
  at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:5592)
  at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:60)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:63)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleItem (TransactionExecutor.java:169)
  at android.app.servertransaction.TransactionExecutor.executeTransactionItems (TransactionExecutor.java:101)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:80)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2719)
  at android.os.Handler.dispatchMessage (Handler.java:109)
  at android.os.Looper.loopOnce (Looper.java:232)
  at android.os.Looper.loop (Looper.java:317)
  at android.app.ActivityThread.main (ActivityThread.java:8787)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:591)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:871)
Caused by java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bp.w()' on a null object reference
  at com.google.maps.api.android.lib6.impl.ct.i (:com.google.android.gms.dynamite_mapsdynamite@251333035@25.13.33 (260400-0):3)
  at com.google.android.gms.maps.internal.p.bd (:com.google.android.gms.dynamite_mapsdynamite@251333035@25.13.33 (260400-0):133)
  at m.do.onTransact (:com.google.android.gms.dynamite_mapsdynamite@251333035@25.13.33 (260400-0):21)
  at android.os.Binder.transact (Binder.java:1243)
  at com.google.android.gms.internal.maps.zza.zzc (com.google.android.gms:play-services-maps@@19.1.0:2)
  at com.google.android.gms.maps.internal.zzl.onPause (com.google.android.gms:play-services-maps@@19.1.0:2)
  at com.google.android.gms.maps.zzah.onPause (com.google.android.gms:play-services-maps@@19.1.0:1)
  at com.google.android.gms.dynamic.DeferredLifecycleHelper.onPause (com.google.android.gms:play-services-base@@18.4.0:1)
  at com.google.android.gms.maps.MapView.onPause (com.google.android.gms:play-services-maps@@19.1.0:1)
  at com.rnmaps.maps.MapView.onPause (MapView.java:226)
  at androidx.lifecycle.DefaultLifecycleObserverAdapter.onStateChanged (DefaultLifecycleObserverAdapter.kt:27)
  at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent (LifecycleRegistry.jvm.kt:320)
  at androidx.lifecycle.LifecycleRegistry.backwardPass (LifecycleRegistry.jvm.kt:272)
  at androidx.lifecycle.LifecycleRegistry.sync (LifecycleRegistry.jvm.kt:289)
  at androidx.lifecycle.LifecycleRegistry.moveToState (LifecycleRegistry.jvm.kt:142)
  at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent (LifecycleRegistry.jvm.kt:124)
  at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release (ReportFragment.android.kt:190)
  at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPrePaused (ReportFragment.android.kt:129)
  at android.app.Activity.dispatchActivityPrePaused (Activity.java:1627)
  at android.app.Activity.performPause (Activity.java:9219)
  at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1778)
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5679)

React Native Maps Version

1.22.6

What platforms are you seeing the problem on?

Android

React Native Version

0.76.9

What version of Expo are you using?

SDK 52

Device(s)

google Pixel 8 Android 15 (SDK 35), google Pixel 8 Android 14 (SDK 34)

Additional information

I also have react-native-map-clustering installed but it happens even without using this library.

"@react-native-google-signin/google-signin": "^13.2.0",
"expo": "~52.0.42",
"react-native": "0.76.9",
"react-native-map-clustering": "^3.4.2",
"react-native-maps": "1.22.6",

@mattproch mattproch added the bug Something isn't working label Apr 25, 2025
@Luttennet
Copy link

Same problem exactly, is there any news/people succeeded to patch this onPause null problem on background?

@Sky
Copy link

Sky commented Apr 29, 2025

Same here on Android. It's enough to go to another app in task manager and back to our app with map on the screen and it will crash with same stack trace

@Bernardo-ive
Copy link

Same here on Android, using versions
RNM > 1.22.0
RN > 0.78.2

Fatal Exception: java.lang.RuntimeException: Unable to pause activity : java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bp.x()' on a null object reference
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:5157)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:5106)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:5056)
       at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2248)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:257)
       at android.app.ActivityThread.main(ActivityThread.java:8333)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:603)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)


 Caused by java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bp.x()' on a null object reference
       at com.google.maps.api.android.lib6.impl.ct.i(:com.google.android.gms.dynamite_mapsdynamite@251731054@25.17.31 (170300-0):3)
       at com.google.android.gms.maps.internal.p.be(:com.google.android.gms.dynamite_mapsdynamite@251731054@25.17.31 (170300-0):133)
       at m.do.onTransact(:com.google.android.gms.dynamite_mapsdynamite@251731054@25.17.31 (170300-0):21)
       at android.os.Binder.transact(Binder.java:1053)
       at com.google.android.gms.internal.maps.zza.zzc(com.google.android.gms:play-services-maps@@19.1.0:2)
       at com.google.android.gms.maps.internal.zzl.onPause(com.google.android.gms:play-services-maps@@19.1.0:2)
       at com.google.android.gms.maps.zzah.onPause(com.google.android.gms:play-services-maps@@19.1.0:1)
       at com.google.android.gms.dynamic.DeferredLifecycleHelper.onPause(com.google.android.gms:play-services-base@@18.4.0:1)
       at com.google.android.gms.maps.MapView.onPause(com.google.android.gms:play-services-maps@@19.1.0:1)
       at com.rnmaps.maps.MapView.onPause(MapView.java:226)
       at androidx.lifecycle.DefaultLifecycleObserverAdapter.onStateChanged(DefaultLifecycleObserverAdapter.kt:27)
       at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
       at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.kt:266)
       at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.kt:283)
       at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.kt:136)
       at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.kt:119)
       at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release(ReportFragment.kt:192)
       at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPrePaused(ReportFragment.kt:131)
       at android.app.Activity.dispatchActivityPrePaused(Activity.java:1455)
       at android.app.Activity.performPause(Activity.java:8365)
       at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1691)
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:5145)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:5106)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:5056)
       at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2248)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:257)
       at android.app.ActivityThread.main(ActivityThread.java:8333)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:603)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@erickbennett
Copy link

erickbennett commented May 8, 2025

same ish issue, but not using google sign in or expo

rn 0.76.9
rn maps 1.23.7
android api 35

reproduce:
launch app
access map
navigate to another app page
send app to background

app will stop responding
logcat displays similar to above - unable to pause… null pointer exception… com.google.maps.api.android.lib6.impl.bq.w()

@nastasiiakyr
Copy link

Totally the same issue.
If don't open screen with map everything works as should, but after opening map, going back and try to send app to background - app crashes.
But at the same time sending the app to background while map screen is open doesn't crash the app.

Any methods of unmounting don't help so far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants