react-native-serial-port-api icon indicating copy to clipboard operation
react-native-serial-port-api copied to clipboard

W/unknown:ReactNative: Calling JS function after bridge has been destroyed

Open miumiu316 opened this issue 3 years ago • 4 comments

The react-native-serial-port-api works well from start of the react native app, but when restart the app from RNRestart Libiary or DevSettings.reload() method, the react-native-serial-port-api seems have some issues, see below scenario: 1 Start APP--react-native-serial-port-api, send and receive OK, the "dataReceived" event is triggered on the java script side

2 Reload the APP using RNRestart Libiary(https://github.com/avishayil/react-native-restart) or using DevSetting.reload() or just "r" from the console. the first time when react-native-serial-port-api can send out the Data out, and from Physical Layer there is data response back, but the "dataReceived" event is not triggered on the java script side, from the second time send out the data, the react-native-serial-port-api works normal on send and receive.

3 see below logs from Android Studio: 2021-08-29 19:59:25.537 30148-30362/com.inst.hct802h I/serialport: send: 550500000002aa 2021-08-29 19:59:26.045 30148-30326/com.inst.hct802h W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["dataReceived",{"data":"FFFFFFFFFFFF0600180042FE174005070108009B0837050401260200101701"}])

4 by Search the google, seems above behavior might be the context is destroyed when RNRestart or DevSetting.reload, and the react-native-serial-port-api is using the old old react context before restart or reload.

5 see reference saying it might be triggered by the the RCTDeviceEventEmitter module trying to send a message to javascript. https://stackoverflow.com/questions/45972220/react-calling-js-function-after-bridge-has-been-destroyed-how-to-find-which

Help Needed: are there any thoughts that we can workaroud of this behavior from the react-native-serial-port-api libiary or the RN side?

miumiu316 avatar Aug 30 '21 13:08 miumiu316