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

fix: DataChannel not emitting new data on iOS #123

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

tamimattafi
Copy link
Contributor

@tamimattafi tamimattafi commented Aug 6, 2024

Problem

In our project, we use data channels to notify other peers that some state has changed (mic, camera, and other stuff)

On iOS, data channels work for 4-5s after the connection is established then they stop emitting data in onMessage flow, while sending data still works properly (Only receiving data was broken)

After digging a little deeper in the app, I found out that my collectors (subscription to data flow) are always active, they just don't receive anything. This applies to all flows (onMessage, onClose...)

It seemed like an internal problem in webrtc, so I cloned the library and started logging and making some changes. I found out that the delegate stops receiving callbacks after a short time, which looks like something is reassigning it, or it's getting cleared somewhere.

Solution

This solution might be weird, but it works. Before making these changes, I could repeat the problem 10 times out of 10, but after the changes, I couldn't repeat it anymore.

I think having a strong reference of the delegate prevents it from being cleared, therefore it's always active.

I would love to hear your thoughts on this :)

@tamimattafi tamimattafi changed the title fix: ios data channel not emitting new data fix: DataChannel not emitting new data on iOS Aug 7, 2024
@tamimattafi
Copy link
Contributor Author

@shepeliev Hello! Is there a possibility to have a review for this PR?

Copy link
Owner

@shepeliev shepeliev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @tamimattafi!

Thank you for PR.

LGTM.

@shepeliev shepeliev merged commit 55e23a5 into shepeliev:main Aug 7, 2024
4 checks passed
@tamimattafi
Copy link
Contributor Author

@shepeliev Thank you! Looking forward to have this in upcoming patches :)

@tamimattafi tamimattafi deleted the fix/ios_data_channel branch August 8, 2024 10:16
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 this pull request may close these issues.

2 participants