keijiro / KlakNDI

NDI® plugin for Unity
https://ndi.video
Other
750 stars 135 forks source link

NDI Stream stops once Unity iOS app is minimized and reopened #144

Open katemilleker opened 2 years ago

katemilleker commented 2 years ago

I've integrated KlakNDI into my Unity app to stream the screen of my iPad to another display screen. When the app is launched for the first time, the NDI stream from my iPad is received by an NDI receiver. Once the app is minimized, the NDI receivers lose the signal and source from the iPad (as expected). However, when the app is reopened from background, the stream is not resumed on the receiver and the NDI receivers can no longer find the source (the Unity iOS app + Game View on my tablet). I've tested with the NDI Studio Monitor and a TouchDesigner NDI In CHOP/TOP.

Is there something I can do to resume/restart the NDI Sender stream from the Unity app after the app has been minimized and reopened from the background?

NDI Sender component - Keep Alpha is off, Capture Method is Game View Unity v.2019.4.35f1 KlakNDI v.2.0.3 iPad Pro (12.9-in), 5th Gen, iOS 15.3.1 TouchDesigner v.2021.16410

keijiro commented 2 years ago

If I remember correctly, it works without any special care. I wonder if it's an unknown issue.

keijiro commented 2 years ago

I wonder if it can be solved by manually disabling/enabling the sender component in OnApplicationPause.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html

katemilleker commented 2 years ago

Unfortunately that doesn't fix the issue, the NDI source is still lost after minimizing the app. Debug Logs in XCode (not present in the script below) showed that OnApplicationPause and OnApplicationFocus were being called as expected when the app was minimized and reopened.

The "NDI Sender" GameObject: NdiSenderGameobject

The new "Application Paused" GameObject: ApplicationPausedGameobject

My script for toggling the sender component via OnApplicationPause/Select ApplicationPausedCSharp