-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I'm seeing a crash when going to full screen mode via F12.
Exception in thread "Thread-4" java.lang.IllegalStateException: Component must have a valid peer
at java.desktop/java.awt.Component$FlipBufferStrategy.flip(Component.java:4171)
at java.desktop/java.awt.Component$FlipBufferStrategy.show(Component.java:4298)
at wolf3d.infra.GameCanvas$MainLoop.run(GameCanvas.java:118)
at java.base/java.lang.Thread.run(Thread.java:1575)
and
Exception in thread "Thread-4" java.lang.IllegalStateException: Buffers have not been created
at java.desktop/sun.awt.X11.XComponentPeer.getBackBuffer(XComponentPeer.java:1143)
at java.desktop/java.awt.Component$FlipBufferStrategy.getBackBuffer(Component.java:4144)
at java.desktop/java.awt.Component$FlipBufferStrategy.flip(Component.java:4164)
at java.desktop/java.awt.Component$FlipBufferStrategy.show(Component.java:4298)
at wolf3d.infra.GameCanvas$MainLoop.run(GameCanvas.java:118)
at java.base/java.lang.Thread.run(Thread.java:1575)
You can easily reproduce this by spamming clicking on F12 if you don't see the issue the first time.
I believe the issue has something to do with threading.
the method to go to full screen disposes the window:
JavaWolf3DGameEngine/src/wolf3d/infra/Display.java
Lines 65 to 76 in 7fbad43
| public void setFullscreenMode() { | |
| dispose(); | |
| setUndecorated(true); | |
| setVisible(true); | |
| //System.out.println("fullscreen supported: " | |
| // + gd.isFullScreenSupported()); | |
| gd.setFullScreenWindow(this); | |
| gd.setDisplayMode(fullscreenDisplayMode); | |
| gameCanvas.updateAspectRatioDimension(); | |
| gameCanvas.requestFocus(); | |
| hideMouseCursor(); | |
| } |
but the main game loop is trying to access the buffer, these are the two places i see crashing:
| Graphics2D g = (Graphics2D) bs.getDrawGraphics(); |
| bs.show(); |
Metadata
Metadata
Assignees
Labels
No labels