[Lemur] Weird Picker AssertionError when minimizing the game window


#1

I’ve been trying to record the game using OBS.
Because I’m on windows 10, the OS comes with virtual desktops.

So I had OBS on one desktop and the game running on an other.

When I was ready to record, I “paused” the game (i.e. disabling everything but Lemurs’ app states) and switched to the other desktop.

I then get this AssertionError :

java.lang.AssertionError
	at com.jme3.math.Ray.setDirection(Ray.java:479)
	at com.jme3.math.Ray.<init>(Ray.java:84)
	at com.simsilica.lemur.event.PickEventSession.getPickRay(PickEventSession.java:370)
	at com.simsilica.lemur.event.PickEventSession.cursorMoved(PickEventSession.java:457)
	at com.simsilica.lemur.event.MouseAppState.dispatchMotion(MouseAppState.java:93)
	at com.simsilica.lemur.event.BasePickState.update(BasePickState.java:169)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:287)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:236)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:367)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:450)
	at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:295)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:125)
	at com.chevreuilgames.retroflashyrpg.Game_Main.main(Game_Main.java:115)

It also happens not just when we switch virtual desktop but also when the window is minimized…

After investigating a bit, I realized that this assertion only happens when the GUI is listening to mouse events with the picker. To me. It seems that somehow the picker isn’t deactivated when the window is minimized,

Any help is appreciated.


#2

As I recall, JME doesn’t provide listeners for window state. So libraries like Lemur out out of luck if they want to adjust themselves based on this.

Unfortunately, this leaves it up to the application to deal with it as they can override the appropriate methods on Application/SimpleApplication and enable/disable things as the window is minimized/restored.

It’s long been on my todo list to add this capability to JME so that there is a proper window state listener so app contexts and other components can know when the window is focused/minimized, etc…


#3
setLostFocusBehavior(LostFocusBehavior.PauseOnLostFocus);

This works.

We can do that because our game is not multiplayer. It also does not need to run in background.