Forum rules - please read before posting.

A slight lag when autosaving.

edited December 2015 in Technical Q&A
 I use autosave at the start when changing levels. I use start delay 0.8
in my cutscene, because the new level fades in. If I use just zero the
autosave snaps a picture of the previous level but loads the correct one (the new one)

There is a slight lag, sort of screen freez when doing autosaving with delay.
Without autosaving or setting delay to zero the level's transition is very smooth with no hinges. But as I mentioned then autosave snaps the picture of the previous level.

Is there any way to improve this?

I tried to check load levels asynchronously, but I think the proble is
when the engine either takes a snap picture of the screen or saves the
data.

 Or it could be that the game runs smoothly but that picture snap shows for a brief second what it captured. And thus making us think it lags. Can this picture snap be doen with out showing what has been captured?

Comments

  • So you're referring to save-game screenshots?

    Are you crossfading to the new scene?  If you're crossfading, then autosaving right at the start will show the previous scene as an overlay - if it was removed for the sake of screenshotting, then the player would also see it flicker off and on again.
  • Yeah, I'm crossfading it.
  • edited December 2015
    That's why I'm using delay 0.8  in my cutscene autosave so the new level fades in completely and the autosave picture then is taken.

    But what I'm thinking Chris, is that this can not possibly be a lag. As I mentioned this is porbably the autosave screen captures and shows us for a brief second what it snapped.
    And this asks the questions if it is possible for the autosave to take the picture but not show it while it does in the game?

    This lag can be observed if you have lots of animations and particle emiters in your scene, you can easily see how the game stops when autosave takes a picture and shows it.

    I really want to use autosave feature for my game.
    But I'm afraid to hear people complaining "This game F lags bad!"
  • The lag is percieved, rather than the frame rate slowing down, because of the way the crossfade effect works: if takes a snapshot of the viewport, displays it full-screen, cuts the camera, and then fades the snapshot out.

    And as I said in my first post: it's not possible to remove the effect during the autosave process without the player noticing it.  I'm not sure there's much that can be done about it.
  • No, no, no,  you got me wrong here.
    Let's leave the crossfading comlpetely out of it.
    Crossfading is completed and out of the question.

     Now when I do autosave, let's say I just run autosave when crossfading is done long ago. Then you can see that lag when autosave takes snapshot. And as I mentioned before this is probably due to the autosave taking picture and showing it and then hiding it quickly. So when you have lot's of animations and particle emitters running, everything would stop for a second when autosave takes that picture.
     
     It could be that saving the data is causing the freez lag, but I think it's the austosave taking the picture and showing it.
  • There's an easy way to test that: just disable the screenshot-taking feature and see if the lag goes away.  I suspect that it is because of the screenshot, but the process by which it does so is as fast as I can make it.  If you want to have a go at playing with it yourself, you can find it in SaveSystem.cs - it's the TakeScreenshot coroutine starting line 322.
  • edited December 2015
    Yes! Just tried to check if it was caused by the autosave taking a snapshot by turning the screenshot-taking feature off like you suggested and the lag is gone now. But of course no screen saves now in the loads and saves windows.
    Will have to look into coroutine now.
  • edited December 2015
    Well not much can be done in that takescreenshot function. Tried to change texture format got same results.

     However I found PreScreenshotBackup function, that made me thinking I could change and keep menus and cursor on (visible) and make an autosave when I leave a scene. The screen always freezes when you leave/end a scene, so anyway making autosave there upon changing/ending the scene would be sensible instead of having a  lag freez at the start of a new scene.

    Thanks Chris.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.