KlakNDI icon indicating copy to clipboard operation
KlakNDI copied to clipboard

Android receiver return black screen

Open tomsuperman opened this issue 2 years ago • 11 comments

Hi, Thanks for this amazing plugin.   I tried to implement the Android NDI Receiver followed with the instruction. The Receiver works fine with my Samsung s10e. However, I recently updated my phone with OS update, the App returned the black screen without any video output. I check the Android Studio, there was no errors or warnings. It seems it cannot initiated the NDI network to find any sender signal. I do not know if this is anything to do with the latest update with Android. Any instruction will be much appreciated.

tomsuperman avatar Dec 13 '22 06:12 tomsuperman

to add more clarifications, the Plugin works great on iOS.

tomsuperman avatar Dec 13 '22 06:12 tomsuperman

Could you try wired connection using USB-ethernet adapter or something like that?

keijiro avatar Dec 13 '22 09:12 keijiro

Thanks for the reply. I just did plug in a USB-ethernet adapter, but still black screen. I did try to add the dropdown to list the OBS senders which works in the Editor. But no items were listed in Android.

tomsuperman avatar Dec 13 '22 10:12 tomsuperman

to Update. I tried to find an older phone without recent security update from Android. The NDI receiver works perfectly fine. So I think the issue may related to the recent update for Android.

tomsuperman avatar Dec 13 '22 10:12 tomsuperman

@keijiro could you check if this is related to the late update from Android? Thanks.

tomsuperman avatar Dec 13 '22 13:12 tomsuperman

It works on my Pixel 5 with Android 13.

keijiro avatar Dec 13 '22 13:12 keijiro

@keijiro Hi, I changed the Target API Level to Android 11.0(API Level 30), and it worked fine. It seems the API level neet to adjust below 31. I do not konw if there is any API restriction for the plugin.

tomsuperman avatar Dec 14 '22 14:12 tomsuperman

Thank you very much for the valuable information, but hmm... I'm not sure why it solves the problem, either.

keijiro avatar Dec 14 '22 14:12 keijiro

@keijiro, I looked more into this issue and found out something may related to this outcome.

https://developer.android.com/about/versions/12/behavior-changes-12#mdnsresponder

"Android 12 changes when apps can interact with the mDNSResponder daemon using the [mDNSResponder native API]. Previously, when an app [registered a service on the network] and called the [getSystemService()]method, the system's NSD service started the mDNSResponder daemon, even if the app had not called any NsdManager methods yet. The daemon then subscribed the device to the all-nodes multicast groups, causing the system to wake more frequently and use additional power. To minimize battery usage, in Android 12 and higher the system now starts the mDNSResponder daemon only when it is needed for NSD events and stops it afterwards."

So I think the getSystemService in Android Helper cannot initialized mdnssd service due to this change. The workaround is to build below API 31 (that's what I did in the last reply). Is there any ways to modify the code to allow unity to call NsdManager directly to avoid this issue?

tomsuperman avatar Dec 30 '22 17:12 tomsuperman

For anyone who has the same issue, one fix is to create an Android plugin and add a NSD Register Service to create a mddns section at beginning. I believe there are other ways, but this one works for me.

tomsuperman avatar Jan 06 '23 12:01 tomsuperman

For anyone who has the same issue, one fix is to create an Android plugin and add a NSD Register Service to create a mddns section at beginning. I believe there are other ways, but this one works for me.

@tomsuperman This sounds very promising, thank you for the investigation! I'm not sure what you mean by "create an Android plugin and add a NSD Register Service."

Can you share how you accomplish this? I have a feeling my app is failing to initialize the mddns service.

Building Android 32 from Unity, by the way. Target platform is Quest 2. My builds that target Android 30 work fine.

eeease avatar Feb 12 '24 20:02 eeease

I think this issue was solved in the latest version (2.1.1). Please reopen it if it still reproduces.

keijiro avatar Jun 12 '24 09:06 keijiro