--
---
You received this message because you are subscribed to the Google Groups "PlayN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to playn+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I don't think this will happen. Though if you're seeing it happen, maybe there's something I'm missing in my hypothesis.
When a GameActivity goes away, the GameViewGL that's associated with that activity also goes away, and so presumably does the GL context used by that GL game view. So all of the original textures (on the GL side) from the first game activity are destroyed along with the context. The Texture Java objects may linger around as garbage, and when their finalizer is run, they will queue up a runnable to delete the texture but that runnable will never get run, because it's queued up on the old GameActivity "game thread" which was driven by the old GameViewGL "onDrawFrame" callback, which is never going to be called again.There is the wrinkle of invokeLater calling runOnUiThread if the game is paused, and we can assume the game is paused in this case, but the activity is also presumably destroyed, so I'm not sure what Android does if you call runOnUiThread on a destroyed activity.
My guess is that it either throws an exception immediately, or just never runs the callback. In either case, it makes more sense for this callback to be done strictly on the game/GL thread, so I'll change it to use that instead.
I assume that there may be some differences; in iOS, when the GLKViewController is removed from the view and the game is "paused", invokeLater will end up queuing the operation via NSOperationQueue.getMainQueue(). This is not directly related to the GLKViewController that was just removed, so I assume that the action will actually run...
Won't this break the case when dispose() is called from the finalizer, if there's no game loop anymore?
On Thu, Mar 21, 2019 at 9:42 AM Guillermo Rodriguez Garcia <guille.r...@gmail.com> wrote:I assume that there may be some differences; in iOS, when the GLKViewController is removed from the view and the game is "paused", invokeLater will end up queuing the operation via NSOperationQueue.getMainQueue(). This is not directly related to the GLKViewController that was just removed, so I assume that the action will actually run...It is possible that the wrong thing could have happened on iOS since as you say the main operation queue is probably still running (assuming your app is still running). So the change I just pushed may in fact fix your problems on iOS.
Won't this break the case when dispose() is called from the finalizer, if there's no game loop anymore?This should not be a problem for the same reason it's not a problem on Android. If the PlayN instance that managed the game loop has been disposed, then it will have destroyed the GL context that it was using to render, and when the GL context is destroyed, all textures are destroyed as well. So the individual Texture Java objects can just be collected at that point. They of course do not know that this happened, so they will need to still queue up a request to destroy their texture, but it can be safely dropped.There appears to be no way to explicitly destroy or dispose of an EAGLContext on iOS, but I assume that when the RoboViewController and the GLKView that created and were using the context eventually go away, that the EAGLContext will be garbage collected itself and destroyed, and all associate GPU resources (like textures) will be cleaned up.