Android JME3 resets custom camera view sizes each time the display is turned on

Just a heads-up about an edge case when using the Camera on Android systems. On Android, when the user turns the display off and on again, any Camera is reset to the full screen dimensions, even if it had a view smaller than that (and is associated with a viewport not filling the entire screen).

What happens is that there is a ‘changed screen size’ event propagating from OGLESContext via AndroidHarnessFragment, LegacyApplication and the RenderManager to the Camera object(s) associated with all on-screen Viewports.

What happens in RenderManager.notifyReshape(int w, int h) is that the camera is resized to the width and height of the current screen.

This happens even if the actual screen size hasn’t changed.

This doesn’t matter if the Camera view is the same size as the screen (which is the case most of the time).

However, if you have a custom camera size (e.g. in my case, I have two viewports, each filling half of the screen), this messes with the viewport rendering (the size of the viewport stays the same, but the view is now “zoomed in”).

As a workaround, you can create a subclass of Camera where the resize() method is overridden and where this is handled (e.g. by modifying width or height to maintain a given aspect ratio).


Please submit an issue on the GitHub page, so we can keep track of it.

Also, can you please provide a minimal test case?

By the way, do you notice the same issue on the Desktop as well when resizing the window? because that will also trigger RenderManager.notifyReshape().

1 Like