Skip to content

Commit 84c0adb

Browse files
committed
fix: solve the problem of the locked canvas with 'waitFor'.
1 parent aefe1c5 commit 84c0adb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglCanvas.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ public void run() {
492492
}
493493

494494
LOGGER.log(Level.FINE, "Using LWJGL {0}", Version.getVersion());
495+
496+
// HACK: If you use waitFor(), unlock it beforehand to initialize the
497+
// context on the fly.
498+
synchronized (createdLock) {
499+
created.set(true);
500+
createdLock.notifyAll();
501+
}
495502

496503
while (true) {
497504
if (needResize.getAndSet(false)) {
@@ -552,7 +559,7 @@ public void run() {
552559
// All this does is call swapBuffers().
553560
// If the canvas is not active, there's no need to waste time
554561
// doing that.
555-
if (renderable.get() && canvas.hasContext()) {
562+
if (renderable.get() && canvas.hasContext() && canvas.isValid()) {
556563
try {
557564
if (allowSwapBuffers && autoFlush) {
558565
// calls swap buffers | lock, etc.
@@ -715,6 +722,7 @@ protected void createContext(AppSettings settings) {
715722

716723
canvas.createContext();
717724
canvas.makeCurrent();
725+
canvas.validate();
718726

719727
// This will activate the "effective data" scrubber.
720728
if (settings.getBoolean("GLDataEffectiveDebug")) {

0 commit comments

Comments
 (0)