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

libdatachannel won't play with Python #973

Open
wusspuss opened this issue Sep 9, 2023 · 3 comments
Open

libdatachannel won't play with Python #973

wusspuss opened this issue Sep 9, 2023 · 3 comments

Comments

@wusspuss
Copy link

wusspuss commented Sep 9, 2023

In the demonstration you can find a translation of the media-receiver example into pure C. It works fine. wrapper.py calls the very same C code, except as a foreign function from within Python - and it seems to work at first, but then it fails randomly, like
Sometimes the camera will turn off before you even copy the browser response to the terminal window
Sometimes it will stream for a bit and then turn off the camera and hang
Sometimes the camera will stay on but no video window will pop up - no datagrams will be reported as being received either

Initially I wanted to write Python bindings for libdatachannel - I started testing them by rewriting media-receiver using my bindings, but it would fail every other time, inconsistently. I thought my bindings were at fault, or maybe the fact that callbacks were in Python - but as the above example shows, it seems the Python interpreter merely being in the same process upsets libdatachannel somehow.

@wusspuss wusspuss changed the title libdatachannel won't play along with Python libdatachannel won't play with Python Sep 9, 2023
@paullouisageneau
Copy link
Owner

Thank you for the demonstration. I'm unable to reproduce on my side, both the C executable and the Python wrapper work as expected, the video displays fine after a couple seconds and it's stable. I have tried multiple restarts and could let it run fine for half an hour, with both Firefox and Chromium as browser. I linked against libdatachannel 0.19.1 with default settings (libjuice backend), and Python is version 3.11.5 on my system.

The symptoms sounds more like something happening with the browser, webcam, or JS script, as libdatachannel should have nothing to do with turning off the camera, especially before the connection is even established. Are you sure the issues are specific to the Python wrapper? I see that you opened discussion #974 mentioning similar problems with the C media-receiver, could you please clarify?

@wusspuss
Copy link
Author

wusspuss commented Sep 9, 2023

Upon further trials I discovered that the C example I did and now even the original C++ example can get this behavior. I am terribly sorry for my inconsistency with this, but that is only because the results I am getting are inconsistent, e.g. sometimes two runs in a row can provide different results...
I am so completely lost at this point. I would blame the browser, but I get this behavior with both Firefox and Chromium. I would blame the hardware, but I have Zoom calls from this machine with no issues. I'm not even sure I can blame the library - I couldn't be the only one getting the errors.

I have no idea what to do at this point. If this might help, I captured the output of the original media-receiver when it fails. In this particular run the camera LED stayed on but the video never came up, and also pressing any key to exit wouldn't work for some time. The only way I modified media-receiver is I set the verbose logging level.

The only good news is if the original media-receiver causes no issue for you, so should be able to use my incomplete but already usable bindings generated with python-cffi with no issue, and maybe some people may find those somewhat useful in their projects.

I have node idea how to troubleshoot this further. I guess I'll try booting from livecd and seeing if that changes things, or try a different machine if I get my hands on one...

@wusspuss
Copy link
Author

wusspuss commented Sep 15, 2023

Welp, still reproducible. Archlinux and Gentoo. Failure rate is higher with Python than it is with C. Also, with C the camera led lights up straight away, but with Python it takes a second or two.

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

2 participants