diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt index 662817b6111dc01abd665b2f6576a6501a01b0e0..77a3a5e72de1eb30c73539f151cd9c293456d3af 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt @@ -813,10 +813,17 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG if (initialized) { Log.d(TAG, "Invoking callback instantly, as map is initialized") runCallback() - } else if (mapView?.isShown != true) { - // If map is not shown, an app (e.g. Dott) may expect it to initialize anyway – before showing it - Log.d(TAG, "Invoking callback instantly: map cannot be initialized because it is not shown (yet)") - runCallback() + } else if (mapView?.isShown == false) { + /* If map is hidden, an app (e.g. Dott) may expect it to initialize anyway and + * will not show the map until it is initialized. However, we should not call + * the callback before onCreate is started (we know this is the case if mapView is + * null), otherwise that results in other problems (e.g. Gas Now app not + * initializing). + */ + mapView?.post { + Log.d(TAG, "Invoking callback now: map cannot be initialized because it is not shown (yet)") + runCallback() + } } else { Log.d(TAG, "Delay callback invocation, as map is not yet initialized") initializedCallbackList.add { runCallback() }