react-native-agora icon indicating copy to clipboard operation
react-native-agora copied to clipboard

engine.release(); 异常

Open yirenkeji555 opened this issue 2 years ago • 8 comments

image

example 中 hook/JoinChannelVideo/JoinChannelVideo.tsx 使用报错

yirenkeji555 avatar Oct 11 '22 10:10 yirenkeji555

image

yirenkeji555 avatar Oct 11 '22 10:10 yirenkeji555

@LichKing-2234 I can reproduce the same error with:

      try {
        console.log('release type: ', typeof engine.current.release);
        engine.current.release();
      } catch (e) {
        console.log('release error: ', e);
      }

log:

 LOG  release type: function
 LOG  release error: [TypeError: undefined is not a function]

EkaanshArora avatar Oct 12 '22 14:10 EkaanshArora

@EkaanshArora What is engine.current?

LichKing-2234 avatar Oct 13 '22 03:10 LichKing-2234

@LichKing-2234 it's likey a useRef usage

radko93 avatar Oct 13 '22 12:10 radko93

It's just a ref that holds the IRtcEngine object returned by createAgoraRtcEngine:

let engine = useRef();
engine.current = createAgoraRtcEngine();

EkaanshArora avatar Oct 13 '22 14:10 EkaanshArora

@EkaanshArora but in demo file use "useState" const [engine] = useState(createAgoraRtcEngine());

yirenkeji555 avatar Oct 13 '22 14:10 yirenkeji555

For immutable values in React it's recommended to use a ref. Nevertheless, the error with the release method is consistent across both usages.

EkaanshArora avatar Oct 13 '22 14:10 EkaanshArora

@EkaanshArora I already use "useRef", but not work. image

image

yirenkeji555 avatar Oct 13 '22 15:10 yirenkeji555

@LichKing-2234 I updated our v3.x quickstart example to v4.0.0 it reproduces this issue. You can test it here.

 LOG  JoinChannelSuccess {"channelId": "test", "localUid": 4131065458}
 LOG  UserJoined {"channelId": "test", "localUid": 4131065458} 2620116037
 LOG  release error: [TypeError: undefined is not a function]

EkaanshArora avatar Oct 18 '22 18:10 EkaanshArora

Will be fixed in the 4.1.0 version.

LichKing-2234 avatar Oct 19 '22 06:10 LichKing-2234

Will be fixed in the 4.1.0 version.

I have same issues. How to most succinctly unregister all listenners when engine.release() throw above error? @LichKing-2234

vietdung97 avatar Dec 14 '22 15:12 vietdung97

@vietdung123 you can call removeAllListeners before release

LichKing-2234 avatar Dec 16 '22 06:12 LichKing-2234