Closed chakrihacker closed 4 years ago
@mikehardy, @luancurti sry for pulling you into this PR, can you please try to test??
@chakrihacker I've tested your code and I release a new version of my app with your fix. Great Job! 🎉 👏
I won't have time, I'm sorry but kudos to @luancurti for giving it a go and for doing the PR in the first place @chakrihacker 💪
Released as 1.1.2
Does this fix, happened on 1.1.1
java.lang.RuntimeException: Unable to pause activity {com.caribu.Caribu/com.caribu.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.marketing.ViewIndexer.unschedule()' on a null object reference
java.lang.NullPointerException
com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4062)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4017)
at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:3969)
at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1836)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6702)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:911)
Caused by: java.lang.NullPointerException:
at com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused (CodelessActivityLifecycleTracker.java:129)
at android.app.Application.dispatchActivityPaused (Application.java:248)
at android.app.Activity.onPause (Activity.java:1731)
at androidx.fragment.app.FragmentActivity.onPause (FragmentActivity.java:470)
at com.facebook.react.ReactActivity.onPause (ReactActivity.java:49)
at android.app.Activity.performPause (Activity.java:7329)
at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1465)
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4052)
@UberMC yes I believe it fixes exactly that.
My related commit in my project:
ike@isabela:~/work/Kullki/ksocialscore/packages/public-app (rebranding) % git show -p 0f3f22a14cbabf0c19e8d9c7d0c126b76fe6806b
commit 0f3f22a14cbabf0c19e8d9c7d0c126b76fe6806b
Author: Mike Hardy <github@mikehardy.net>
Date: Mon Feb 3 11:30:31 2020 -0500
public-app: react-native-fbsdk integrated crash fix
diff --git a/packages/public-app/package.json b/packages/public-app/package.json
index 66604d6..8a1ae98 100644
--- a/packages/public-app/package.json
+++ b/packages/public-app/package.json
@@ -177,7 +177,7 @@
"react-native-device-info": "^5.4.3",
"react-native-elements": "^1.2.6",
"react-native-emoji": "^1.8.0",
- "react-native-fbsdk": "^1.1.1",
+ "react-native-fbsdk": "^1.1.2",
"react-native-firebase": "~5.6.0",
"react-native-fs": "^2.16.2",
"react-native-gesture-handler": "^1.5.3",
diff --git a/packages/public-app/patches/react-native-fbsdk+1.1.1.patch b/packages/public-app/patches/react-native-fbsdk+1.1.1.patch
deleted file mode 100644
index 1899278..0000000
--- a/packages/public-app/patches/react-native-fbsdk+1.1.1.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff --git a/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBAccessTokenModule.java b/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBAccessTokenModule.java
-index ee66e1d..bfdf5d7 100644
---- a/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBAccessTokenModule.java
-+++ b/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBAccessTokenModule.java
-@@ -47,9 +47,11 @@ public class FBAccessTokenModule extends ReactContextBaseJavaModule {
- private final AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
- @Override
- protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
-- mReactContext
-- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
-- .emit(CHANGE_EVENT_NAME, currentAccessToken == null ? null : Utility.accessTokenToReactMap(currentAccessToken));
-+ if (mReactContext.hasActiveCatalystInstance()) {
-+ mReactContext
-+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
-+ .emit(CHANGE_EVENT_NAME, currentAccessToken == null ? null : Utility.accessTokenToReactMap(currentAccessToken));
-+ }
- }
- };
-
No crashes since integrating the patch+1.1.1 or using 1.1.2 clean from upstream
@mikehardy still happening here on 1.1.2, lots of crashes on Google Play Console from production users. This is the report:
java.lang.RuntimeException: at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4742) at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4691) at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:4626) at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:45) at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2199) at android.os.Handler.dispatchMessage (Handler.java:112) at android.os.Looper.loop (Looper.java:216) at android.app.ActivityThread.main (ActivityThread.java:7625) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)
Caused by: java.lang.NullPointerException: at com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused (CodelessActivityLifecycleTracker.java:129) at android.app.Application.dispatchActivityPaused (Application.java:260) at android.app.Activity.onPause (Activity.java:1839) at androidx.fragment.app.FragmentActivity.onPause (FragmentActivity.java:470) at com.facebook.react.ReactActivity.onPause (ReactActivity.java:57) at android.app.Activity.performPause (Activity.java:7663) at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1536) at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4726)
This seems like a different issue. Also I don't see any code related to the react-native bindings, looks like a bug in the facebook sdk. Maybe updating the version could fix it.
@janicduplessis thanks for replying.
Weird enough I'm using react-native-fbsdk 1.1.2 (latest) and RN 0.61.5, followed step by step for autolink config, works well on iOS but Google Play Console is showing hundreds of crashes daily on production from users. Opened an issue for this but not sure what is happening ( https://github.com/facebook/react-native-fbsdk/issues/750 ).
Seems like some people also had the same issue ( https://github.com/facebook/react-native/issues/24498#issuecomment-524234973 ).
I am also facing this issue. I'm using RN 0.61.5 and react-native-fbsdk 1.1.2.
java.lang.NullPointerException Attempt to invoke virtual method 'void com.facebook.marketing.ViewIndexer.unschedule()' on a null object reference
@Hamawis v2.0.0 is out, reporting issues on old versions and closed PRs is likely to result in not a thing happening
This PR fixes Crash when handling access token by tracking access token when react context is ready
Fixes #675