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

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

Closed

Description

@bsudekum

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

Activity

  1. tobrun commented on Jan 18, 2016

    @tobrun
    Member

    Linking #3573.

  2. tobrun commented on Jan 18, 2016

    @tobrun
    Member

    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.

  3. tobrun commented on Jan 18, 2016

    @tobrun
    Member

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

  4. tobrun commented on Jan 19, 2016

    @tobrun
    Member

    @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.

  5. bsudekum commented on Jan 19, 2016

    @bsudekum
    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.

  6. bleege commented on Jan 19, 2016

    @bleege
    Contributor
  7. tobrun commented on Jan 20, 2016

    @tobrun
    Member

    @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

  8. added
    Android
    on Jan 20, 2016
  9. tobrun commented on Jan 20, 2016

    @tobrun
    Member

    @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.

  10. zugaldia commented on Feb 3, 2016

    @zugaldia
    Member

    @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

  11. bsudekum commented on Feb 10, 2016

    @bsudekum
    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)
    
  12. tobrun commented on Mar 6, 2016

    @tobrun
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions