Skip to content

Android crash caused by nulled eventEmitter #109

@mbpictures

Description

@mbpictures

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

Hi!

Thanks for this awesome library! After upgrading to version 3.0.0 we got a lot of crashes in our firebase crashlytics:

          Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.bridge.CxxCallbackImpl.invoke(java.lang.Object[])' on a null object reference
       at com.orientationdirector.NativeOrientationDirectorSpec.emitOnDeviceOrientationChanged(NativeOrientationDirectorSpec.java:37)
       at com.orientationdirector.OrientationDirectorModule.sendOnDeviceOrientationChanged(OrientationDirectorModule.kt:53)
       at com.orientationdirector.implementation.EventManager.sendDeviceOrientationDidChange(EventManager.kt:13)
       at com.orientationdirector.implementation.OrientationDirectorModuleImpl.onDeviceOrientationChanged(OrientationDirectorModuleImpl.kt:159)
       at com.orientationdirector.implementation.OrientationDirectorModuleImpl._init_$lambda$0(OrientationDirectorModuleImpl.kt:30)
       at com.orientationdirector.implementation.OrientationSensorsEventListener.notifyDeviceOrientationChanged(OrientationSensorsEventListener.kt:102)
       at com.orientationdirector.implementation.OrientationSensorsEventListener.onOrientationChanged(OrientationSensorsEventListener.kt:73)
       at android.view.OrientationEventListener$SensorEventListenerImpl.onSensorChanged(OrientationEventListener.java:151)
       at android.view.OrientationEventListener$CompatSensorEventListenerImpl.onSensorChanged(OrientationEventListener.java:192)
       at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:1100)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.nextDeliQueue(MessageQueue.java:780)
       at android.os.MessageQueue.next(MessageQueue.java:760)
       at android.os.Looper.loopOnce(Looper.java:196)
       at android.os.Looper.loop(Looper.java:367)
       at android.app.ActivityThread.main(ActivityThread.java:9333)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)

It seems like the eventEmitter, which is called emitOnDeviceOrientationChanged, is null.

Library version

3.0.1

Environment info

info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.26200
  CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
  Memory: 24.27 GB / 63.77 GB
Binaries:
  Node:
    version: 24.14.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 4.4.1
    path: C:\Users\mbpic\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 8.12.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowAllTrustedApps: Enabled
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22000.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 16.11.35026.282 (Visual Studio Community 2019)
    - 17.10.35122.118 (Visual Studio Community 2022)
Languages:
  Java:
    version: 17.0.9
    path: C:\Program Files\Microsoft\jdk-17.0.9.8-hotspot\bin\javac.EXE
  Ruby:
    version: 3.2.3
    path: C:\Ruby32-x64\bin\ruby.EXE
npmPackages:
  "@react-native-community/cli":
    installed: 20.1.0
    wanted: 20.1.0
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.84.1
    wanted: 0.84.1
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to reproduce

I was not able to reproduce it locally; it only appears in production (but there it happens for a lot of users).

Reproducible example repository

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions