Skip to content

Commit

Permalink
8271395: Crash during printing when disposing textures
Browse files Browse the repository at this point in the history
Reviewed-by: kcr, prr
  • Loading branch information
FlorianKirmaier authored and kevinrushforth committed Aug 20, 2022
1 parent cedc17c commit 8815981
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,23 @@ public static <T> T runWithRenderLock(Supplier<T> supplier) {
}
}

public static void runInRenderThreadAndWait(Runnable runnable) {
try {
CountDownLatch latch = new CountDownLatch(1);
QuantumRenderer.getInstance().execute(() -> {
try {
runnable.run();
} catch (Throwable e) {
e.printStackTrace();
}
latch.countDown();
});
latch.await();
} catch (Throwable e) {
e.printStackTrace();
}
}

boolean hasNativeSystemVsync() {
return nativeSystemVsync;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package com.sun.prism.impl;

import com.sun.javafx.tk.quantum.QuantumToolkit;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.PhantomReference;
Expand Down Expand Up @@ -126,6 +128,10 @@ public static void disposeRecord(Disposer.Record rec) {
* thread on which the resources were created).
*/
public static void cleanUp() {
if (!Thread.currentThread().getName().startsWith("QuantumRenderer")) {
QuantumToolkit.runInRenderThreadAndWait(() -> cleanUp());
return;
}
disposerInstance.disposeUnreachables();
disposerInstance.processDisposalQueue();
}
Expand Down

1 comment on commit 8815981

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.