Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[Android] Annotation do not open info when clicked #3584

Closed
bsudekum opened this issue Jan 16, 2016 · 12 comments
Closed

[Android] Annotation do not open info when clicked #3584

bsudekum opened this issue Jan 16, 2016 · 12 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@bsudekum
Copy link

I've been trying to debug this issue now in react-native land for a while. Symptoms:

  • Touching an annotation marker does not open the infowindow
  • However, I can log events with setOnMarkerClickListener. The event fires but there is no infowindow
  • When rotating the map, if the annotation was clicked, the info window appears
  • When rotating back upright, the infowindow is displayed when clicked normally
  • (Also, the map becomes very distorted when rotated, this can be handled in another ticket)

I'm not certain if this is a react native bug or a gl-native bug. Perhaps react is clobbering touch events on initial load?

/cc @brentvatne @tobrun @zugaldia @bleege

@tobrun
Copy link
Member

tobrun commented Jan 18, 2016

Linking #3573.

@tobrun
Copy link
Member

tobrun commented Jan 18, 2016

This should be resolved when #3573 lands.
Notice that this will be merged to the release branch of 3.1.0 and not on master.

@tobrun
Copy link
Member

tobrun commented Jan 18, 2016

Landed with 74a9c50 on release branch of 3.1.0 in #3537.

@tobrun tobrun closed this as completed Jan 18, 2016
@tobrun
Copy link
Member

tobrun commented Jan 19, 2016

@bsudekum also happy to report that #3156 will land with release of 3.1.0.
The related PR has some great improvements for touch handling on Android.

@bsudekum
Copy link
Author

@tobrun - @bleege put out a snapshot that included this fix. After testing, I'm still seeing that I cannot open marker annotations on the initial load without rotating the map first.

@bsudekum bsudekum reopened this Jan 19, 2016
@bleege
Copy link
Contributor

bleege commented Jan 19, 2016

Just noting that the SNAPSHOT with the fix is https://oss.sonatype.org/content/repositories/snapshots/com/mapbox/mapboxsdk/mapbox-android-sdk/3.1.0-SNAPSHOT/mapbox-android-sdk-3.1.0-20160119.193839-22.aar and it's based on the latest code in release-android-v3.1.0 branch.

@tobrun
Copy link
Member

tobrun commented Jan 20, 2016

@bsudekum now by properly reading through your use-case I think the source of your problem can be found downstream rather than upstream. I have never saw this behaviour on Android GL before. I will do some debugging in react when I'm picking up nitaliano/react-native-mapbox-gl#249

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Jan 20, 2016
@tobrun
Copy link
Member

tobrun commented Jan 20, 2016

@bsudekum
I wanted to take a look at this issue by debugging react-native, but I'm having trouble finding documentation for setting up my development environment to contribute to react-native. I have created this issue for nitaliano/react-native-mapbox-gl#252.

@zugaldia
Copy link
Member

zugaldia commented Feb 3, 2016

@bsudekum I see that on Android react-native-mapbox-gl does not include the required activity lifecycle methods.

From looking at the React Native docs, it seems there're two possible ways to fix this, both within the ReactNativeMapboxGLModule class. Could you check if either of them help with this issue? (I'm sorry, I don't have a working React Native set up at the moment).

Option 1: Via the Application object.

getCurrentActivity().getApplication().registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        aPackage.getManager().getMapView().onCreate(savedInstanceState);
    }

    @Override
    public void onActivityStarted(Activity activity) {
        // see onActivityCreated
    }

    @Override
    public void onActivityResumed(Activity activity) {
        // see onActivityCreated
    }

    @Override
    public void onActivityPaused(Activity activity) {
        // see onActivityCreated
    }

    @Override
    public void onActivityStopped(Activity activity) {
        // see onActivityCreated
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
        // see onActivityCreated
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        // see onActivityCreated
    }
});

Option 2: Via the addLifecycleEventListener method.

reactContext.addLifecycleEventListener(new LifecycleEventListener() {
    @Override
    public void onHostResume() {
        aPackage.getManager().getMapView().onResume();
    }

    @Override
    public void onHostPause() {
        // see onHostResume
    }

    @Override
    public void onHostDestroy() {
        // see onHostResume
    }
});

Option 1 seems to be the better option as it includes the full cycle, not just a subset of it. Either way, I believe we should leave one of them in the code as not including these methods is a common source of errors in the SDK.

/cc: @bleege @tobrun

@bsudekum
Copy link
Author

Option 1 gives the following error:

02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React: Exception in native call from JS
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLModule.<init>(ReactNativeMapboxGLModule.java:37)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage.createNativeModules(ReactNativeMapboxGLPackage.java:21)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:751)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:688)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:84)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:177)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:162)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at android.os.AsyncTask$2.call(AsyncTask.java:288)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-11 07:45:20.798 10642-10642/com.testbed E/unknown:React:     at java.lang.Thread.run(Thread.java:818)

Option 2 gives the following error:

02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React: Exception in native call from JS
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.views.MapView.onResume()' on a null object reference
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLModule$1.onHostResume(ReactNativeMapboxGLModule.java:37)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.facebook.react.bridge.ReactContext.onResume(ReactContext.java:140)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.moveReactContextToCurrentLifecycleState(ReactInstanceManagerImpl.java:761)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.setupReactContext(ReactInstanceManagerImpl.java:599)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.access$700(ReactInstanceManagerImpl.java:84)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.onPostExecute(ReactInstanceManagerImpl.java:187)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.onPostExecute(ReactInstanceManagerImpl.java:162)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at android.os.AsyncTask.finish(AsyncTask.java:632)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at android.os.AsyncTask.access$600(AsyncTask.java:177)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at android.os.Handler.dispatchMessage(Handler.java:102)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at android.os.Looper.loop(Looper.java:135)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at android.app.ActivityThread.main(ActivityThread.java:5292)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at java.lang.reflect.Method.invoke(Native Method)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at java.lang.reflect.Method.invoke(Method.java:372)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
02-11 07:42:51.013 6937-6937/com.testbed E/unknown:React:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

@tobrun
Copy link
Member

tobrun commented Mar 6, 2016

Closing this issue as this is an downstream issue in react-native rather than an Android SDK one.

@tobrun tobrun closed this as completed Mar 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

4 participants