RestartLevel has lag/delay on restart for multiple reasons. Is there a better alternative?

We’re making a game where the player dies constantly and has to restart from scratch in a randomized level. The problem is that when we execute the console command “RestartLevel”, it was taking 8 seconds to restart when playing it on the phone. However, in the editor it restarts immediately.

In the process of trying to figure out what was causing lag on restart on the phone, I was able to decrease the time in several ways:

  1. Reduced the scene to only a cube and directional light.

  2. Deleted our Mesh folder holding all 20 of our characters and more meshes.

  3. Removed dynamic shadows.

  4. Deleted our Materials folder with 30+ materials (Keep in mind that the cube in the scene at this point wasn’t even using any of these materials. But deleting this folder reduced the restart time by about 1 sec)

After all this, the restart time was reduced from 8 seconds to less than 1 sec…My theory is that the RestartLevel command reloads everything in the game from scratch again, regardless if anything in the scene is using it or not.

The only possible solution I can think of right now is to manually reset everything in the level to their default locations with “Set World Location”, “Set Rotation”, “Destroy Actor”, reset score to “0”, etc. in order to simulate a restart. This just seems like way too much work.

I also came across the same problem with “Open Level” & “Reset Level” nodes. Has anyone come across any alternative solutions to restarting or can provide any insight as to why RestartLevel does this? Thanks in advance!

Hi RommelDumaguin,

  • What device are you deploying to?
  • Does this occur in a clean, blank project with no additional content or is it limited to one project?
  • What steps are you taking to restart the level? Are you simply running the console command or is there more involved?

Hello ! Thanks for the reply.

  • We are deploying to Android phones. This one in particular is an HTC Evo. We notice the delay issue on an a newer phone as well, but it’s just magnified and more noticeable on this Evo.
  • I tried migrating the Mesh & Materials folders to a clean scene and as I suspected, they did not add any noticeable delay on restart (refer to next bullet point).
  • We’re simply running the “RestartLevel” command through the “Execute Console Command” node upon tapping on the screen after the player dies. The delay still occurs after running the command from a trigger, or upon death.

To troubleshoot further, upon migrating the Meshes & Materials folder (only has Meshes & Materials obviously) back to our project after deleting them, the delay is no longer there. Of course the project no longer works because references to the meshes and materials are broken…

try using “fix up redirectors” after moving the assets. Does this help resolve the broken references?

Unfortunately it didn’t resolve the broken references. Thanks for that tip though!

Can you send me a sample project this is occurring in? I’ll be happy to take a look and see what may be going on.

I’ll try and get a sample project set up and link it here. Unless you have a better idea of how I can get you the project? I couldn’t find a messaging option.

That will probably be the most efficient means to provide the sample project. Uploading to a trusted FTP site, such as Dropbox or googledrive, then providing the link will allow me to get access to the sample project.

Hi RommelDumaguin,

We have not heard from you in several days. I am marking this thread as answered for tracking purposes. If you are still experiencing this error, please comment with the requested information.

So far it looks like the only way I can get you a sample is to send you our actual game project. You can understand how tough that is, especially if it’s going to be linked to everyone. I apologize.

I wonder if deleting those folders does anything else other than breaking references. My thought is that breaking the references is what speeds up the restart time. I wish there was a fast and efficient way to test this instead of deleting the folders (and migrating them back in) or altering these referenced nodes one by one.

I will report any findings when I get a chance. Thanks.

Hello again ! Sorry for the delay but I was able to get a build for you. I hope that you get this and can find time to take a look:

https://drive.google.com/file/d/0B3oW4gs7v9Kyb3JTaVFLZk5MX28/view?usp=sharing

If you have any questions on where anything is or how anything is setup please don’t hesitate to ask. What I can tell you about that build is that it still has the references setup. Launching that build onto my Android Evo takes about 6+ seconds to restart after tapping the screen. Deleting the Materials & Meshes folder and relaunching reduces that time to about 2.5 to 3.5 seconds.

I attempted this in 4.11 preview and have seen no lag with restarting. It seems to restart within .5-1 second of the tap occurring. Do you have any other specific steps I can take to reproduce this on my end? Have you tried creating a copy of your project in a later build to see if you get the same delays?

Hmm…I will try 4.11 preview as well on my end next…

Something I noticed is that the restart lag doesn’t seem to occur in unreal. Only after it’s been deployed to the android phone. We’ve deployed to 2 android phones and a tablet. All experience the same delay with varying restart times depending on how old the device is. The delay is troublesome because taps register before the map is fully loaded from the RestartLevel command.

Have you had a chance to try this on 4.11 preview? Do you still see the same error?

Yeah, but what’s weird is that the game loads with “Your Splash Screen Here” and then crashes/closes the game after 10 seconds or so. This is after wiping any trace of the previous version off of the phone.

Do you have any specific steps I can take for the launch that may reproduce this. As of yet I have not experienced these delays or crashes on my end.

Interesting. I’m looking into it. The issue only occurs when it’s launched from the phone. I will try another build as well. Thanks.

So I tried 4.10 and it’s not loading the game all the way either. It seems like updating our game to a newer build makes it worse by adding additional problem/s. I’m guessing that the only way you will be able to reproduce the issue is to launch the game onto a mobile phone. Preferably an older android phone. I’m testing with a Android HTC Evo.3d.

Do you have any more recent phones to test on? I’ve tested on an s5 without the errors you are experiencing.

Yes. We tested on a more recent phone, and while it was fast, the delay was still noticeable and causes any touch input during that delay to be applied when the level finishes loading. Do you know of any other ways to restart the level other than the “RestartLevel” command, or the open/load level nodes? It seems like the restart time would be significantly faster if we just manually add blueprint code to move everything back in their original position with default values, scores reset, etc. upon death. That just seems like a horrible solution.