Skip to content
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

Fixed crash caused by Android map lifecycle methods being called out of order. #1273

Conversation

timxyz
Copy link
Contributor

@timxyz timxyz commented Apr 26, 2017

We found an intermittent crash caused by LifecycleEventListener.onHostResume being called after doDestroy. This caused an internal crash in MapView, presumably due to its onResume method being called after onDestroy.

Crash was as follows:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.o()' on a null object reference
       at com.google.maps.api.android.lib6.impl.da.b(:com.google.android.gms.DynamiteModulesB:96)
       at com.google.android.gms.maps.internal.z.onTransact(:com.google.android.gms.DynamiteModulesB:73)
       at android.os.Binder.transact(Binder.java:380)
       at com.google.android.gms.maps.internal.IMapViewDelegate$zza$zza.onResume(Unknown Source)
       at com.google.android.gms.maps.MapView$zza.onResume(Unknown Source)
       at com.google.android.gms.dynamic.zza$7.zzb(Unknown Source)
       at com.google.android.gms.dynamic.zza.zza(Unknown Source)
       at com.google.android.gms.dynamic.zza.onResume(Unknown Source)
       at com.google.android.gms.maps.MapView.onResume(Unknown Source)
       at com.airbnb.android.react.maps.AirMapView$12.onHostResume(AirMapView.java:302)
       at com.facebook.react.bridge.ReactContext$1.run(ReactContext.java:165)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5272)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

This PR also adds in previously missing onStart and onStop calls: the docs expect the MapView to receive the lifecycle methods of its parent activity or fragment, and so we should try to replicate such a lifecycle as closely as possible with the AirMapView.

@christopherdro
Copy link
Collaborator

/cc @felipecsl

@felipecsl
Copy link
Contributor

I'd like to avoid these band-aid solutions for Android crashes and do it the proper way through #1306 instead. I'll keep open until that one merges, so if @timxyz can retest and we can make sure it fixes the problem :)

@timxyz
Copy link
Contributor Author

timxyz commented May 8, 2017

#1306 does not seem to address this crash at all. I can still see the same problems in AirMapView.

@felipecsl
Copy link
Contributor

@timxyz have you tried the code in that pull request directly?

@timxyz
Copy link
Contributor Author

timxyz commented May 8, 2017

I will try it out tomorrow, I was just inspecting it visually for now to see what had changed. There are still missing lifecycle calls.

@felipecsl
Copy link
Contributor

I don't think onHostResume would ever be called for the same Activity after onHostDestroy though

@rborn
Copy link
Collaborator

rborn commented Mar 4, 2020

Closing as being an old PR and not a clear reply. Thanks for all the effort 😻

@rborn rborn closed this Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants