Stutter when showing Monarch screen containing a Distance Field font with a shadow

I can’t seem to get rid of a stutter that happens when I show a Monarch screen for the first time. Subsequent monarch.show()'s are fine.

The “Preload” flag has been ticked, but this only seems to move the stutter a few frames earlier.

The curious thing about this is that it happens for all screens, even if they’re virtually empty (one text node and one box node) and minimal code in the .gui_script.

Aside from the above, is there anything else I could do to avoid this stutter?

Edit: Removing things in sequence until there was no stutter revealed the culprit: Shadow Alpha and Shadow Blur. When both set to 0, the stutter disappears. Is it possible to pre-cache the fonts?!

Edit 2: Changing the font to Bitmap also removes the issue, but then the shadow doesn’t work (it becomes square blocks).

Does this happen when testing on desktop or on mobile?

There’s a transition or something that stutters?

I have no idea why this happens… @jhonny.goransson or @JCash any idea?

iPhone 11 Pro, mostly. :flushed:

First the phone freezes for 2 frames, then the FPS gets shaky for a few seconds, then comes back to normal. If no shadows are used, there is no freezing or FPS drop at all.

Not sure why it would be that much heavier. SUre, each glyph has 3 layers instead of one.

As for caching, for each uncached glyph, we, upload the glyph texture to the larger cache texture.
Before that, we unpack the glyph texture as well.

I guess if there are a lot of new glyphs to be uncompressed and uploaded the first frame, it will stutter.

We don’t have a handy preworming function currently yet.

You should be able to prewarm it by incrementally adding a few glyphs to an (invisible/hidden) text node each frame.

2 Likes

Since it’s a distance field, would it be enough to pre warm the glyphs at one point size, or would all used point sizes have to be cached separately?

At that stage, there is no point size, only the rasterized size that you chose for the font.
So, for each fontfile you’ll have to prewarm.

2 Likes

That’s great. Then my plan to cache all glyphs during loading might work. Will try it out tomorrow.

Edit: Ok, I’ve managed to get it to work! There is a caveat, though: The collection with the cached fonts needs to always be visible/in memory. If it’s unloaded, the stutter starts happening again.

2 Likes