Giter VIP home page Giter VIP logo

Comments (6)

mwh1r avatar mwh1r commented on September 10, 2024 1

Am also experiencing this crash after upgrading react-native-reanimated to v3. Looks like there is some sort of conflict between reanimated and the onSuccess/onError events that this library emits.

The way the react native docs state to emit events differs from how this library is doing it and updating this library's code to the recommended approach happens to also bypass the problem (by using RCTEventEmitter instead of EventDispatcher).

Here is an example of a patch using patch-package that can be used until myself or someone else raises a PR.

diff --git a/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetView.java b/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetView.java
index 369672c..2f0610a 100644
--- a/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetView.java
+++ b/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetView.java
@@ -13,8 +13,7 @@ import com.facebook.react.bridge.ReactContext;
 import com.facebook.react.bridge.ReadableMap;
 import com.facebook.react.bridge.WritableMap;
 import com.facebook.react.bridge.Arguments;
-import com.facebook.react.uimanager.UIManagerModule;
-import com.facebook.react.uimanager.events.EventDispatcher;
+import com.facebook.react.uimanager.events.RCTEventEmitter;
 import com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback;
 import com.google.android.gms.maps.StreetViewPanorama;
 import com.google.android.gms.maps.model.LatLng;
@@ -70,16 +69,15 @@ public class NSTStreetView extends StreetViewPanoramaView implements OnStreetVie
         this.panorama.setPanningGesturesEnabled(allGesturesEnabled);
         this.panorama.setStreetNamesEnabled(!streetNamesHidden);
 
-        final EventDispatcher eventDispatcher = ((ReactContext) getContext())
-                .getNativeModule(UIManagerModule.class).getEventDispatcher();
+        Context context = getContext();
+        ReactContext reactContext = (ReactContext)context;
 
         this.panorama.setOnStreetViewPanoramaCameraChangeListener(new StreetViewPanorama.OnStreetViewPanoramaCameraChangeListener() {
             @Override
             public void onStreetViewPanoramaCameraChange(StreetViewPanoramaCamera streetViewPanoramaCamera) {
                 if (!(streetViewPanoramaCamera.bearing >= 0 ) && coordinate != null) {
-                    eventDispatcher.dispatchEvent(
-                            new NSTStreetViewEvent(getId(), NSTStreetViewEvent.ON_ERROR)
-                    );
+                    reactContext.getJSModule(RCTEventEmitter.class)
+                            .receiveEvent(getId(), "onError", null);
                 }
             }
         });
@@ -91,13 +89,11 @@ public class NSTStreetView extends StreetViewPanoramaView implements OnStreetVie
                     WritableMap map = Arguments.createMap();
                     map.putDouble("latitude", streetViewPanoramaLocation.position.latitude);
                     map.putDouble("longitude", streetViewPanoramaLocation.position.longitude);
-                    eventDispatcher.dispatchEvent(
-                            new NSTStreetViewEvent(getId(), NSTStreetViewEvent.ON_SUCCESS, map)
-                    );
+                    reactContext.getJSModule(RCTEventEmitter.class)
+                            .receiveEvent(getId(), "onSuccess", map);
                 } else {
-                    eventDispatcher.dispatchEvent(
-                            new NSTStreetViewEvent(getId(), NSTStreetViewEvent.ON_ERROR)
-                    );
+                    reactContext.getJSModule(RCTEventEmitter.class)
+                            .receiveEvent(getId(), "onError", null);
                 }
             }
         });
diff --git a/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetViewManager.java b/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetViewManager.java
index 595b5c1..75a87b6 100644
--- a/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetViewManager.java
+++ b/node_modules/react-native-streetview/android/src/main/java/co/il/nester/android/react/streetview/NSTStreetViewManager.java
@@ -55,9 +55,10 @@ public class NSTStreetViewManager extends SimpleViewManager<NSTStreetView> {
     @Override
     public @Nullable
     Map getExportedCustomDirectEventTypeConstants() {
-        return MapBuilder.of(
-                NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_ERROR), MapBuilder.of("registrationName", NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_ERROR)),
-                NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_SUCCESS), MapBuilder.of("registrationName", NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_SUCCESS))
-        );
+        return MapBuilder.builder()
+            .put("onSuccess",
+                    MapBuilder.of("registrationName", "onSuccess"))
+            .put("onError", MapBuilder.of("registrationName", "onError"))
+            .build();
     }
 }

from react-native-streetview.

Windastella avatar Windastella commented on September 10, 2024

Same issue here. I'm debugging it at the moment. I will update when I found the root cause.

from react-native-streetview.

Windastella avatar Windastella commented on September 10, 2024

These are the log for the crash.

java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: can't call java.lang.String java.lang.Object.toString() on null object
java_vm_ext.cc:577]     in call to CallObjectMethodV
java_vm_ext.cc:577]     from void com.swmansion.reanimated.nativeProxy.EventHandler.receiveEvent(java.lang.String, com.facebook.react.bridge.WritableMap)

Seems to be related to re animated. The last changes I did make before the crash happen is to update the Re-Animated Package from v2 to v3. Probably worth testing on your implementation. @ccriptdev7

from react-native-streetview.

Windastella avatar Windastella commented on September 10, 2024

Downgraded my react-native-reanimated from v3 to v2. That solved the issue for now.

from react-native-streetview.

ccriptdev7 avatar ccriptdev7 commented on September 10, 2024

Yes exactly. I downgraded my react-native-reanimated to v2 which resolved the issue. However, downgrading react-native-reanimated caused problems in my iOS apps. I hope there's a path for this.

from react-native-streetview.

amitpdev avatar amitpdev commented on September 10, 2024

fixed in v0.2.4
thanks for your work @mwh1r

from react-native-streetview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.