When using my app if a user moves on to another app and then come back in there is just a black screen. The interaction and audio is still there, also the draw function is still being called, but all there is to be seen is a black screen.
Its been a while since I released an iOS app but I believe the OS can delete / clear GPU memory and textures if needed when losing focus.
I think you might need to cache the fbo contents during lost focus and re-allocate the fbo and restore the contents in got focus. You could do this with readToPixels and then save the contents to disk.
The functions in ofApp should provide those callbacks.
ah ok, that makes sense with what I’m seeing. I have setup a much simpler project and the FBOs etc have been working as expected, but its a much lighter program, so it might as you say be being released by the OS, and then not being reallocated (because I’m not currently reallocating on getting focus)
I’ve had a go at deallocating and then reallocating from the gotFocus function, but that hasn’t worked. The thing that is strange to me is that after regaining focus I can’t even see a circle that I’m drawing on the top of the draw stack outside of any FBO
I tried the solve from @danoli3 but that hasn’t changed anything. @theo have also had a go with a couple of examples and I’m not getting the issue. Very strange. I have implemented a swift share sheet in the app, I uncommented it’s usage to test if that was the problem, but I know that Xcode does some strange things with hidden bridge files or something. I don’t know if that’s potentially causing issues?
I’ve had another few goes at it, and still couldn’t get the solution @danoli3 set out to work.
I tried using .allocate before drawing to the FBOs again in the fashion set out above, however it still doesn’t work when it hits .begin().
@danoli3 When you say “regenerateTexturesNow()” is that effectively:
or is it
After some more digging, there’s a bit more info and context:
I have a small vector of FBOs that get redrawn every frame, these are then drawn to another FBO which is drawn alongside 2 others. So 3 “top level” FBOs. If I just update and draw the vector of FBOs without the “top level” FBOs it works fine, but when it hits the first .begin() of any of the “top level” FBOs ALL drawing stops.
If I use fbo.getTexture().bind() and fbo.getTexture().unbind() then drawing works again, but it has some really strange issues ie. the only FBO drawn is the previous one updated, regardless of whether or not that fbo’s draw function is called.
So, although the underlying issues still exist to a degree, using the above post, and the link above I now have an app which is landscape only and doesn’t have it’s FBOs messed up by losing and gaining focus.
This does however make the swift share sheet that I implemented rotated 90degrees, which takes me back to this issue: