react-native-unity
react-native-unity copied to clipboard
Android hard crash Fatal Exception: java.lang.NullPointerException
About 5% of our Android users are experiencing this Crash. We are currently using React-Native-Unity version 1.0.6, the current latest. This crash seems to affect various Android devices and various Android OS as well. I have not been able to reproduce the issue myself, and it does not seem to affect iOS. Let me know if anyone has an idea of what could be going on.
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference at com.azesmwayreactnativeunity.ReactNativeUnity.createPlayer(ReactNativeUnity.java:40) at com.azesmwayreactnativeunity.ReactNativeUnityViewManager.createViewInstance(ReactNativeUnityViewManager.java:54) at com.azesmwayreactnativeunity.ReactNativeUnityViewManager.createViewInstance(ReactNativeUnityViewManager.java:27) at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:183) at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:115) at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281) at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:909) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026) at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches() at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:984) at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:30) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7720) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)
+1 this is also happening to me in prod environment. @azesmway any advice here would be much appreciated. It is our only crash in production.
Hi
change ReactNativeUnity.java
public static void createPlayer
add existence check activity
if (activity) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
...
}
Hi
change ReactNativeUnity.java
public static void createPlayer
add existence check activity
if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { ... }
@azesmway Thank you! I just created a pull request with this change. Could you possibly deploy a patch to npm including the pull request so our team (and the others out there) can use this fix without having to create a separate npm package from a forked repo?