[Android, UMF] FPlatformMisc::ControlScreensaver(Disable) breaks Unreal Media Framework playback

Engine Version: 4.7.5

Project Type: C++

Full Source Code: No

Android Device: Samsung Galaxy Note 3 (SM-N9005)

Android Version: 4.4.2


The Issue

Note that this problem only happens on the Android device. PC/iOS is working fine.

We are currently implementing movie playback for our game and switched to Unreal Media Framework (Media Player), because the Startup Movie hack suddenly stopped working for us. All is working fine if implemented in a blank project, but in our project the render target texture becomes invisible/transparent. After disabling our custom game instance, we noticed it started working again.

We had this line in our custom GameInstance to disable the screensaver from starting:

FPlatformMisc::ControlScreensaver(FPlatformMisc::EScreenSaverAction::Disable);

After commenting out this line the movie playback started working again. We have experimented with turning the screensaver on/off at different locations in code and blueprint, and it seems it will disable movie playback permanently if the screensaver is ever disabled.

We have not tried the startup movie playback hack again after finding this issue, but we suspect it is related to the same problem.

1 Like

Hi Denny,

We are unable to reproduce your issue in house with the running 5.0.1. Further, weā€™re able to confirm that the screensaver control is working as intended.

Can you give me your device and its version, as well as attaching any to this thread as a txt file?

Thanks much!

I will get back to you tomorrow with when I am back at the office, if I get any messages to appear at all that is.

The device and version can be seen in the original post.

I just noticed during play testing that UMF fails to play videos if the game goes to screensaver mode and comes back into the game. Videos will never play again until I close the app, clear it from memory and start up again.

Sorry about missing your device and version; your thread composition is much nicer than many, too. :smiley: Thanks for checking on , weā€™ll keep checking on this end in the meantime.

No worries! I couldnā€™t help but look around in the code to understand how the screensaver stuff is handled. Backtracking the ControlScreensaver code, I notice it ends up in AndroidMisc, which then finally ends up in GameActivity.java.

In AndroidThunkJava_KeepScreenOn() the FLAG_KEEP_SCREEN_ON is added to the layoutparams.

I see in other troubleshooting threads online that this flag doesnā€™t always work as intended? I see developers talking about requesting a WakeLock instead, as in the threads below.

Then Iā€™ve also seen multiple threads that Android 5.0 have a lot of new stuff under the hood that works different to previous android versions.

I still donā€™t get how a lock screen / screensaver mode may mess with the movie playback. So Iā€™ll do some exploring there as well. :slight_smile:

Iā€™m still new to how Android handles things, thought Iā€™d just try to stir up some ideas for you guys who are more experienced than meā€¦ Tomorrow I will make sure to test on several more devices at the office to see if itā€™s device specific or not.

Sorry for spamming you with replies. I did a build on a blank project and the same problem happens. I also noticed that the problem happens if I minimize the app and then resume it! Is it possible, that when minimizing the app, that something thread related messes up or something with the screen orientation is causing issues?

I also noticed that the video plays just fine if I minimize in the middle of the video and then return back! It pauses while minimized and resumes on focus without issues. Note however that I canā€™t play the same video again after it finishes!

This order is worth noting:

  1. Game is a simple UMG widget, with a button to play movie.
  2. Start video by pressing button. Plays fine.
  3. Minimize app with home button while video is playing.
  4. Restore app from open apps screen.
  5. Video resumes playing as the game continues to run.
  6. Video can NOT be played again after it ends. (it works flawlessly if the app is not minimized)

So the video playback IS working, but something is preventing it after lock. Is there a state somewhere that is not properly reset, so that the video canā€™t be played on focus again?

Hi Denny! One quick question, Iā€™m hoping to try to repro your issue today. How are you deploying the apk to your device?

I first use the deployment through the file menu. (Android, ETC1) Then I use the bat file to install on the phone.

API version 9. API 14 or above will break due to the JNI (another answerhub thread was opened for that). Shipping or Development build should not matter.

Iā€™m sorry for not getting you any . We got a bunch of other UMF-related problems, so I forgot to get you before heading out for the weekend.

Hi Denny,

Iā€™m passing this issue and the other UMF one to the devs. If you can attach those it will be very helpful in assisting him with these issues.

Thanks!

Hi wittlief, sorry for the delay. I sent you a PM on the forums containing an example project for reproducing the issue.

We returned to using the startup movie functionality due to the issues with UMF and noticed that this screensaver issue also affects the startup movie playback trick. So itā€™s not specific to UMF, but the underlying media player itself.

Here are two Android log files which show you what happens when the video plays, and what happens after the app looses focus and we try again.

[Working - Before Screensaver / Loose Focus][1]

[Broken - After Screensaver / Loose Focus / Return to App][2]

40722-umf_mediaplayer_beforescreensaver.txt (390 KB)
[2]: 40723-umf_mediaplayer_afterscreensaver.txt (73.2 KB)

Hi Denny,

Sorry for the long delay. I heard back from the Android dev about this issue in specific, and heā€™s been unable to reproduce this. Are you still seeing the problem?

No worries wittlief. Yes, we still have the issue. We are not using UMF at the moment, but the other media player (startup movie system) is affected by the exact same issues already mentioned in this thread.

We are using the same trick as mentioned [here][1]. We do the SetupLoadingScreen part, where we load the movie info, and play it. This works perfectly, multiple times in a row, even after switching maps and such. It breaks however, just like UMF does, if we minimize the app and come back.

Repro steps:

  1. Play video in app. All is fine.
  2. Minimize app. (home button)
  3. Open up app again from memory so it resumes where it left off.
  4. Try play video again. This fails on our end. (should be same as the in my previous answer)

Note that the engine does not crash or anything, itā€™s just the media player that fails. (like the previous have shown)

Thanks for trying to solve this issue! We would be really happy if we could get rid of the issue, as itā€™s the only real ā€œbugā€ on our plate right now. Luckily the product still functions, but itā€™s a bit of a bummer that a key part of the game just stops working after minimizing / receiving a phone call / etc. Cheers!

How can I play a .mp4 movie file during the game? - Programming & Scripting - Epic Developer Community Forums

Hi Denny,

Sorry for the long delay, and further, Iā€™m sorry for the lack of specific information in regards to this issue. At this point, the only answer I can give is a non-specific ā€˜we think itā€™s fixed for 4.8ā€™. The Android dev helping me to investigate this has mentioned a number of broad fixes to issues that affect movie/playback have been made for 4.8, and that he hopes that yours was fixed and that is why we were unable to reproduce internally.

At this point, Iā€™d advise you to make a copy of your project and try the most recent 4.8 preview and see if you are still able to reproduce your issue. Definitely make a copy and do not convert directly, just to be on the safe side. Once again, my apologies that I canā€™t point to anything more helpful.

Good luck!

Hi wittlief. I just made a deployment using my UMF test-project at home on 4.8 (Preview 3). It seems that I can continue to play movies after minimizing the app! So it does indeed look promising. Iā€™m pretty sure I tested this on Preview 1, so Iā€™m glad the developers involved managed to get the fixes into this build and not 4.9.

Tomorrow I will do multiple tests in a copy of our real project, to see if all other UMF/MediaPlayer related issues might have been solved. Iā€™ll get back to you as soon as I know more.

Cheers!

We managed to get a build working on 4.8 Preview 3. Despite other crashes and issues due to our quick migration, the videos seem to be working as intended now.

We will wait for the full release for 4.8 to give this a shot again.

Thanks for fixing this.

I have this problem on 4.9ā€¦

Hey ,

In order to better assist you, could you please submit a new question to AnswerHub? Within that new post, could you please provide your , the version of the engine youā€™re on, the type of device youā€™re working on, the version the device is on? Please make sure that you explain exactly whatā€™s happening so that we can help you as quick as possible.

Thanks! :slight_smile: