-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8271395: Crash during printing when disposing textures #618
8271395: Crash during printing when disposing textures #618
Conversation
Switching to the QuantumThread fixes the native crash when cleaning Textures.
👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed the approach yet. Presuming the approach is the right one, the implementation will need some refactoring to move the toolkit-specific logic into the toolkit. I'll provide more feedback when I go to review this.
modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumRenderer.java
Outdated
Show resolved
Hide resolved
/reviewers 2 |
@kevinrushforth |
QuantumRenderer is no longer public
How to proceed to get this PR reviewed? |
@@ -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")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed like a dubious way to detect the render thread so I looked around for how it is done elsewhere but instead I found
com/sun/javafx/sg/prism/NGCanvas.java
private static void runOnRenderThread(final Runnable r) {
// We really need a standard mechanism to detect the render thread !
if (Thread.currentThread().getName().startsWith("QuantumRenderer")) {
And .. it is also used by printing, and I added it in 2013 :-(
In my defence I copied the code from webview as mentioned in https://bugs.openjdk.org/browse/JDK-8094524
oh well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Phil, for digging into this. I was going to question it as well.
I'll file a follow-on bug to add such a method (not super urgent, but it would be worth having a consistent way to do this). I see that I suggested filing such an issue in the JBS issue Phil pointed to, but didn't do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline
@@ -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")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Phil, for digging into this. I was going to question it as well.
I'll file a follow-on bug to add such a method (not super urgent, but it would be worth having a consistent way to do this). I see that I suggested filing such an issue in the JBS issue Phil pointed to, but didn't do it.
public static void runInRenderThreadAndWait(Runnable runnable) { | ||
try { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
com.sun.javafx.tk.quantum.QuantumRenderer.getInstance().execute(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: this is in the same package, so you don't need the full package name. As long as you are making other changes, you might change this, too.
A bigger question is that I think this is the first time we've used execute directly. I'm not sure that's a problem, but want to take a second look at it. The other places where we run a job on the renderer all use Toolkit.getToolkit(). addRenderJob()
, which ultimately calls submit()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the package prefix.
I've just tested it, and the method "submit" is changed by overriding newTaskFor in QuantumRenderer. This has the effect, that calling submit leads to an exception. But calling execute works.
modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java
Show resolved
Hide resolved
changes based on codereview We now catch Throwable instead of Exception
I've worked in the feedback, thank you @kevinrushforth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look fine now. Since this PR is so out of date w.r.t. master, can you merge the upstream master into your PR branch? I'll do some quick testing and then approve it, once you do.
You will also need to update the title of this PR to match the JBS issue (the JBS bug title is the better one), before it can be integrated.
latch.countDown(); | ||
}); | ||
latch.await(); | ||
} catch (Throwable e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether we need to catch Throwable
here, but we use that pattern all over the place in this file, so it can be reexamined as part of the cleanup bug I will file.
@FlorianKirmaier This PR is pending the following:
|
@kevinrushforth |
The Mac build seems to be failing for some reason, unrelated to the PR. |
Yes, that is due to JDK-8292549 which is fixed by the soon-to-be-integrated PR #879 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@FlorianKirmaier This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kevinrushforth, @prrace) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@FlorianKirmaier |
/sponsor |
@kevinrushforth @FlorianKirmaier Pushed as commit 8815981. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR switches the Thread to the QuantumRenderer, in the case the Disposer is called from another Thread - the printing Thread.
I'm open for better solutions on how to fix this Issue.
Initially i thought there is also a Race Condition in the resource pool, but a new one is created for the Printing Thread.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/618/head:pull/618
$ git checkout pull/618
Update a local copy of the PR:
$ git checkout pull/618
$ git pull https://git.openjdk.org/jfx pull/618/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 618
View PR using the GUI difftool:
$ git pr show -t 618
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/618.diff