Forum rules - please read before posting.

Reproducible lag/delay/short freeze after OnStart cutscene

In my first game scene after the OnStart cutscene (which just contains some dialogue lines + character walking around), I unfortunately have a reproducible freeze/lag/delay. It happens in my builds as well as in the editor.

Before this lag there's just a short and simple dialogue line and a variable to be set.
After the lag my "spell inventory" box is being shown (enabled "during gameplay"). This is based on the inventory Menu (same settings, but positioned at the bottom right corner).

At first I thought I may have accidentaly added an engine wait or something, but I didn't.

What else could I check to find out what's causing that lag? It's a bit annoying especially shortly after game start, when players think the whole game might be as laggy (which it isn't).

Comments

  • Are your Menus using Unity UI? By default, AC will spawn on request - i.e. when displayed for the first time - as opposed to all at once when the game begins.

    Does the lag disappear if you instead lock your Inventory menu, so that it doesn't appear once gameplay begins? If so, what are the asset contents of it - i.e. the UI Canvas assets and the Inventory item textures?

    If not, try using Unity's Profiler window to detail the cause of the spike.

  • edited October 2024

    Hm, this is interesting. Yes, I am using Unity UI.
    But even if I lock off both the Inventory and the Spells Inventory on game start, I get that spike with more than 600ms for CPU and then GPU as well.
    So I guess ... those spells and inventory menus aren't the problem.

    But I have to find out more about profiling, since I never used that.

  • Enable "Deep Profile", pause the game after the lag, and select the spike. Use the Hierarchy panel of the Profiler and expand the tree with the largest time (ms) value. Share screenshots and I'll take a look.

  • edited October 2024

    With Deep Profile enabled, the spike is even heavier (shot shows GPU Spike, but it's the same for the CPU one ... frame/step later):
    https://imgur.com/a/fpjTvZc

    btw, I have compress save files + save on different thread enabled, but even if I turn it off, it's still the same.

  • The largest ms value I see is on "CloudWorker". I don't know if this helps. Those spikes seem to be mostly in "Scripts" and "Others" if I read the graph correctly, but I'm not sure.

    https://imgur.com/a/WqZfy7j

  • edited October 2024

    In all honesty I've never been able to get my head around the Profiler's "Timeline" view.

    Switch it over to "Hiearchy" and expand the largest contributor.

    Are you saving the game at this time?

  • You are so helpful, Chris, thank you!
    I find this Analyzer rather counter intuitive as well. But in the Hierarchy I think I have now found something quite interesting:
    https://imgur.com/a/VIMivXf

    I haven't implemented a save, but maybe this happens automatically after the first cutscene?

    Indeed the game seems to be saved right then. What I have installed in my project is the Savegame Screenshots "plugin" you provided on your website. Because I like this feature and saves layout.

    Once I set "save screenshots" in those saving settings to "never", the lag was instantly gone!

    I'll disable this for now.

    Do you have an idea how to fix it though? My backgrounds are pretty large with 5760x3240 original size, saved as PNG, but set to 2048 max size and crunch compressed down to 203 kb.

  • Yes, it's the save screenshot that's doing it.

    2048 is still a very large size - I'd recommend reducing it if you can.

    However, the alternative way to supply save-screenshots is to rely on a Render Texture, which may be faster.

    You'd need to create a separate Camera, parented to the MainCamera so that is shows the same view, and then assign it a Render Texture of the intended screenshot size / format. You can then assign this in the Settings Manager, and AC will take a snapshot of this for save-games, rather than generating its own.

  • I'll try this (later), thank you.
    I just wanted to add another information for now:

    I am working with a 4k screen. Players of my game said they didn't notice a lag. They have smaller (fullhd) screens. So this can be a reason as well.

    I'll have to see if the render texture will have the same problem on a 4k screen - unfortunately I don't know if would make a difference when the screen resolution seems to be the reason, technically.

  • It's a different means of getting the pixel data.

  • edited October 2024

    I've added the Screenshot camera, created the render texture asset and assigned it in the camera, as well as in the AC settings.

    Creating the screenshot with the autosave worked without lag, but:

    With this screenshot camera enabled (as parent or child to the main camera), i cannot control my character anymore. Once I click somewhere, the character just walks to the right and stays there.
    Hotspot labels aren't displayed anymore either.

    Any idea how to fix that?

    edit: Ooh okay. It was a wrong camera tagging and "Main Camera" component assignment on my side. Seems to work now. :)

  • There's one thing that confuses me a bit: The rendered texture has much more contrast than the actual screen (and even the render texture preview).

    But I guess I'll have to find out where this effect comes from myself. It's just a note to myself (or to the community, if anyone else stumbled on the same problem) and if I find out what causes this, I'll leave the solution here.

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.