Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RN 0.70 crashes #381

Open
georgeilas-tem opened this issue Sep 20, 2022 · 8 comments
Open

RN 0.70 crashes #381

georgeilas-tem opened this issue Sep 20, 2022 · 8 comments

Comments

@georgeilas-tem
Copy link

georgeilas-tem commented Sep 20, 2022

RN 0.70 deprecated:

AppState.removeEventListener: https://reactnative.dev/docs/appstate#removeeventlistener
Linking.removeEventListener: https://reactnative.dev/docs/linking#removeeventlistener

Both are used in utils.js and cause crashes on Android.

@georgeilas-tem
Copy link
Author

georgeilas-tem commented Sep 20, 2022

Patched it quickly this way:

diff --git a/node_modules/react-native-inappbrowser-reborn/utils.js b/node_modules/react-native-inappbrowser-reborn/utils.js
index 9fe6085..c7ca6e8 100644
--- a/node_modules/react-native-inappbrowser-reborn/utils.js
+++ b/node_modules/react-native-inappbrowser-reborn/utils.js
@@ -5,22 +5,24 @@
 
 import invariant from 'invariant';
 import {
-  processColor,
+  AppState,
   Linking,
+  NativeModules,
   Platform,
-  AppState,
-  NativeModules
+  processColor
 } from 'react-native';
+
 import type {
+  AuthSessionResult,
   BrowserResult,
+  InAppBrowserOptions,
   RedirectEvent,
-  RedirectResult,
-  AuthSessionResult,
-  InAppBrowserOptions
+  RedirectResult
 } from './types';
 
 export const RNInAppBrowser = NativeModules.RNInAppBrowser;
 
+let _redirectListener = null
 let _redirectHandler: ?(event: RedirectEvent) => void;
 
 type AppStateStatus = typeof AppState.currentState
@@ -33,7 +35,7 @@ function waitForRedirectAsync(returnUrl: string): Promise<RedirectResult> {
       }
     };
 
-    Linking.addEventListener('url', _redirectHandler);
+    _redirectListener = Linking.addEventListener('url', _redirectHandler);
   });
 }
 
@@ -42,17 +44,19 @@ function waitForRedirectAsync(returnUrl: string): Promise<RedirectResult> {
  */
 function handleAppStateActiveOnce(): Promise<void> {
   return new Promise(function (resolve) {
+    let listener=null 
+    
     // Browser can be closed before handling AppState change
     if (AppState.currentState === 'active') {
       return resolve();
     }
     function handleAppStateChange(nextAppState: AppStateStatus) {
       if (nextAppState === 'active') {
-        AppState.removeEventListener('change', handleAppStateChange);
+        listener.remove()
         resolve();
       }
     }
-    AppState.addEventListener('change', handleAppStateChange);
+    listener = AppState.addEventListener('change', handleAppStateChange);
   });
 }
 
@@ -137,7 +141,9 @@ export async function openAuthSessionPolyfillAsync(
 
 export function closeAuthSessionPolyfillAsync(): void {
   if (_redirectHandler) {
-    Linking.removeEventListener('url', _redirectHandler);
+    _redirectListener.remove()
+
+    _redirectListener = null
     _redirectHandler = null;
   }
 }

@hstorz
Copy link

hstorz commented Oct 10, 2022

Can confirm, I got the same error on 0.70.2. Could fix the crash with your patch on version 3.6.3, thanks for that!. Would be nice if this could be merged in a new release soon.

@mstiggle
Copy link

Ran into this problem as well, would love to have this merged in to avoid applying a patch.

@LitileXueZha
Copy link

LitileXueZha commented Nov 28, 2022

Also crashed, here is my logcat:

11-28 16:42:56.014 10270 10313 E AndroidRuntime: ob.e: Subscriber class d8.c and its super classes have no public methods with the @Subscribe annotation
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at ob.p.a(Unknown Source:58)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at ob.c.p(Unknown Source:6)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at d8.c.l(Unknown Source:14)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at d8.c.k(Unknown Source:352)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at com.proyecto26.inappbrowser.RNInAppBrowserModule.open(Unknown Source:10)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at com.facebook.jni.NativeRunnable.run(Native Method)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:808)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:101)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:166)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
11-28 16:42:56.014 10270 10313 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:784)

UPDATE: I reallized that my problem may caused by ProGuard, and fixed it through modify proguard-rules.pro 😂🙄 Also found a trick of Android Optimizations from README, however onStart() not worked in RNN...

@melisa-at-levelpath
Copy link

Running in the same issue on android. Any plans on fixing this? 🤔

Same error in logs:

k7.e: Subscriber class o5.c and its super classes have no public methods with the @Subscribe annotation
at k7.p.a(Unknown Source:58)
at k7.c.p(Unknown Source:6)
at o5.c.l(Unknown Source:14)
at o5.c.k(Unknown Source:352)
at com.proyecto26.inappbrowser.RNInAppBrowserModule.open(Unknown Source:10)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147)
at com.facebook.jni.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:1012)

"react-native": "0.71.2"
"react-native-inappbrowser-reborn": "^3.7.0"

@jdnichollsc
Copy link
Member

Hey folks, thanks for reporting this issue! Let me try ASAP! <3

@timorss
Copy link

timorss commented Mar 22, 2023

any news guys?

@LonelyCpp
Copy link

this has been fixed in this PR if I'm not wrong : #297

It handles both appstate and linking compatibility. What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants