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

Crash when releasing the local stream on android #1257

Closed
qusaieilouti99 opened this issue Dec 21, 2022 · 4 comments · Fixed by #1258
Closed

Crash when releasing the local stream on android #1257

qusaieilouti99 opened this issue Dec 21, 2022 · 4 comments · Fixed by #1258

Comments

@qusaieilouti99
Copy link

When releasing the local stream the app crashed on android and this is how we release the stream:

 releaseLocalStream = () => {
        if (this.localStream) {
            this.localStream.release(true);
            this.localStream = undefined;
        }
    }

the crash report:

FATAL EXCEPTION: pool-17-thread-1

java.util.ConcurrentModificationException

FATAL EXCEPTION: pool-17-thread-1
Process: com.pingme2022, PID: 20168
java.util.ConcurrentModificationException
	at java.util.IdentityHashMap$IdentityHashMapIterator.nextIndex(IdentityHashMap.java:734)
	at java.util.IdentityHashMap$ValueIterator.next(IdentityHashMap.java:832)
	at org.webrtc.VideoTrack.dispose(VideoTrack.java:59)
	at com.oney.WebRTCModule.GetUserMediaImpl$TrackPrivate.dispose(GetUserMediaImpl.java:496)
	at com.oney.WebRTCModule.GetUserMediaImpl.disposeTrack(GetUserMediaImpl.java:241)
	at com.oney.WebRTCModule.WebRTCModule.lambda$mediaStreamTrackRelease$16$com-oney-WebRTCModule-WebRTCModule(WebRTCModule.java:821)
	at com.oney.WebRTCModule.WebRTCModule$$ExternalSyntheticLambda16.run(Unknown Source:4)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

Possible solution:
Link

The line causing the issue is 59 in this file: org.webrtc

The issue happened to me only once while doing heavy testing on the video calls.

Expected Behavior

it shouldn't crash

Observed Behavior

it crashed

Steps to reproduce the issue

N/A

Platform Information

  • React Native Version: 0.70.6
  • Plugin Version: 106.0.1
  • OS: Android
  • OS Version: 11
@saghul
Copy link
Member

saghul commented Dec 22, 2022

Can you consistently reproduce this?

I think I know what causes it, we need to run addSink / removeSink in the executor thread, since that's where we call dispose.

@qusaieilouti99
Copy link
Author

It only happened twice and randomly when ending the call.
but I saw that in the call guide in our plugin you don't recommend releasing the local stream : Destoying media stream
but I saw it's outdated so is that correct what I'm doing to release the stream at the end of each call?

@saghul
Copy link
Member

saghul commented Dec 22, 2022

If you no longer need the stream is ok to release it.

saghul added a commit that referenced this issue Dec 22, 2022
Make sure add/removeSink operations run in the WebRTC thread, so it's
safe to dispose and not get an error when concurrently modifying the
sinks container, which happens inside WebRTC.

Fixes: #1257
@8BallBomBom
Copy link
Member

Will update the docs/handbook soon.
Not entirely sure why i didn't include the use of the release function.
Think it might have been due to the assumption that it was done automatically.

Will also run some tests on #1258 👍🏻

saghul added a commit that referenced this issue Jan 11, 2023
Make sure add/removeSink operations run in the WebRTC thread, so it's
safe to dispose and not get an error when concurrently modifying the
sinks container, which happens inside WebRTC.

Fixes: #1257
jatecl pushed a commit to jatecl/react-native-webrtc that referenced this issue Jul 19, 2023
Make sure add/removeSink operations run in the WebRTC thread, so it's
safe to dispose and not get an error when concurrently modifying the
sinks container, which happens inside WebRTC.

Fixes: react-native-webrtc/react-native-webrtc#1257
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

Successfully merging a pull request may close this issue.

3 participants