Quantcast
Channel: Questions in topic: "native plugin"
Viewing all articles
Browse latest Browse all 376

Android Unity, Screen Recording and MediaProjection APIs - UnityPlayerActivity hang.

$
0
0
I work on a project that uses MediaProjectionManager, MediaProjection and VirtualDisplay in order to record game play. This project also switches away from the UnityPlayerActivity and back every couple of minutes. On the latest Unity, after starting my screen recording utility, I then switch to the UnityPlayerActivity: activity.finish(); activity.startActivity({Intent starting the UnityPlayerActivity}); SceneManager.LoadScene()> After doing this, the first time, the UnityPlayerActivity starts just fine, and my game switches from my native activity to my game scene and continues running. When game play finishes, I then switch back to my Native activity by calling static Java methods from UnityScript to trigger the change: unityPlayerActivity.startActivity() My activity then starts up just fine. However, when I go to switch back to the UnityPlayerActivity a second time, it has hung. All rendering stops, and no messages I send it are received. This hang happens no matter which scene I try to trigger, whether or not I try to close out my screen recording utility, and whether or not I try to start my screen recording again on this second switch. At this point, I've narrowed it down to the screen recording via trial and error removal of code, as no exceptions are thrown or logged. I'm fairly certain that the creation of the VirtualDisplay and MediaProjection are causing this issue. mMediaProjectionManager = (MediaProjectionManager) unityPlayerActivity.getSystemService(Context.MEDIA_PROJECTION_SERVICE); mMediaProjection = mMediaProjectionManager.getMediaProjection(mResultCode, mResultData); mVirtualDisplay = mMediaProjection.createVirtualDisplay( "recorder", mStream.getVideoQuality().resX, mStream.getVideoQuality().resY, DisplayMetrics.DENSITY_LOW, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mSurface, null, // callback null // handler ); Removing the creation of these from my screen recording utility clears up all of my problems, as does removing the screen recording utility entirely. This worked fine on Unity 4.x, but upon updating my project to 5.4, it's 100% reproducible. Would anyone have any ideas on what could be going wrong, or how I could debug this issue?

Viewing all articles
Browse latest Browse all 376

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>