This is a huge improvement to the way rendering works on Android. Until now we had to reload the entire app when the GLContext was killed (as is the case when minimising the app, entering the task switcher etc).
Instead, we now store the image's source data in CGImage and use it to re-upload the image data onto the GPU when entering the app again, in the newly recreated GLContext. This means the app and all of its state stays loaded at minimal cost (our PNG sources add up to about 100kb RAM usage). It now looks and feels just like an iOS app 🔥
There are also some related changes to font rendering where statically-stored UIFont instances would not render correctly in a newly-created GLContext. UIFont is now a little more separated from FontRenderer: instead of holding a strong reference to a specific FontRenderer, FontRenderers can be recreated behind the scenes and UIFont accesses the relevant FontRenderer instance dynamically. Aside from the rendering improvements (text stays consistently visible!), this should also fix some crashes when cleaning up fonts.
Finally, we are updating sdl-gpu to avoid crashes when "free"ing a GPU_Image that was created in a now-invalid/destroyed GPU_Renderer context. This was causing crashes in over 5% of sessions and will be a huge quality of life improvement for Android users.
Review note:
I tried to make the commit history clean to allow reviewing the different parts of this PR individually, so I can recommend going through each commit one by one.
Important:
We are now using our own fork of sdl-gpu, so you will probably have to run git submodule sync for git to recognise the changed remote.
Fixes #208 (and more)
This is a huge improvement to the way rendering works on Android. Until now we had to reload the entire app when the GLContext was killed (as is the case when minimising the app, entering the task switcher etc).
Instead, we now store the image's source data in
CGImage
and use it to re-upload the image data onto the GPU when entering the app again, in the newly recreated GLContext. This means the app and all of its state stays loaded at minimal cost (our PNG sources add up to about 100kb RAM usage). It now looks and feels just like an iOS app 🔥There are also some related changes to font rendering where statically-stored
UIFont
instances would not render correctly in a newly-created GLContext.UIFont
is now a little more separated fromFontRenderer
: instead of holding a strong reference to a specificFontRenderer
,FontRenderer
s can be recreated behind the scenes andUIFont
accesses the relevantFontRenderer
instance dynamically. Aside from the rendering improvements (text stays consistently visible!), this should also fix some crashes when cleaning up fonts.Finally, we are updating
sdl-gpu
to avoid crashes when "free"ing a GPU_Image that was created in a now-invalid/destroyedGPU_Renderer
context. This was causing crashes in over 5% of sessions and will be a huge quality of life improvement for Android users.Review note:
I tried to make the commit history clean to allow reviewing the different parts of this PR individually, so I can recommend going through each commit one by one.
Important:
We are now using our own fork of sdl-gpu, so you will probably have to run
git submodule sync
for git to recognise the changed remote.