Non-blocked MoviePlayer that plays across multiple frames

Hi,

During our digging of how to conveal the StreamLoading appearance, we have found the following mechanism:

1. There is a Begin/EndStreamingPause delegate, which is bound to the StreamingPauseRendering module’s implementation by default.

2. The StreamingPauseRendering module use another MoviePlayer widget window to play movies and some slate animations. Basically it relies on the MoviePlayer module’s mechanism.

3. The MoviePlayer module creates another thread so do simple MovieStreaming, slate updating and rendering jobs, at a fixed rate. So it will not be blocked by the main thread and the view keeps moving even when the main thread is blocked flush streaming, etc.

This helps to meet the needs of users who really hate the traditional static loading screen. But sometimes the flush streaming or some other time costy operations come in serveral frames. The way the StreamingPauseRendering module handles will introduce intervals to supposingly continuously played movies. We tried to use the MoviePlayer module directly and manually setup the play/stop time. This does not work because many places in the engine tick function will call MoviePlayer::WaitForMovieToFinish to block itself until the movie playing thread has finished.

We asked on the forum. This post [Content removed] explained that since slate is not thread safe, the MoviePlayer thread can not be fully run indivually from the main thread. It has to be stopped by the main thread some where, before the “slate critical section”.

Is it possible to not fully stop the MoviePlayer, instead try to find a way to sync the MoviePlayer’s updating thread with the main thread? We’ve come up with some pritimive thoughts on this and this is how we think might work:

1. Add another WaitLoop after MoviePlayer’s main loop (which we refer as the UpdateLoop). Encapsulate the two loops together as the new main loop.

2. Somewhere before the “slate critical section”, we force pause the MoviePlayer’s thread, wait for it to enter the WaitLoop before continue.

3. Somewhere in the engine’s tick, if we find there’s a paused MoviePlayer thread, we resume it so it leaves the WaitLoop and enters the UpdateLoop once again.

We were wondering if this would really work, and even if it works how to implement it. Since it involves deep modification into the engine’s ticking process, instead of doing it by ourselves we would like more to see it (or any other similar functions) coming in future versions. so is this mechanism feasible or even planned?

Thanks

Hi,

Slate is designed to be single threaded. One exception was made for the MoviePlayer loading but only because it is expected that the main thread is blocking on WaitForMovieToFinish. Because of events and blueprint callbacks, it’s possible even on a widget creation to call a bunch of public functions that can cause multithreaded effects. One good example of this is the Tick() method on the slate application which eventually needs to draw the windows and compete for the synchronization objects related to rendering.

So, at the moment, we don’t plan on changing this part.

Your idea of splitting the engine loop to introduce more phases would require new synchronization objects which provide new opportunities for race conditions. It would also cause a cost impact in the evaluation loop that happens all the time, even outside of the Loading screen scenario. Perhaps you could make it work for your game, but it’s not something we can impose on all our clients.