Skip to content
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

8295324: JavaFX: Blank pages when printing #916

Conversation

eduardsdv
Copy link
Contributor

@eduardsdv eduardsdv commented Oct 14, 2022

This fixes a race condition between application and 'Print Job Thread' threads when printing.

The race condition occurs when application thread calls endJob(), which in effect sets the jobDone flag to true,
and when the 'Print Job Thread' thread was in the synchronized block in waitForNextPage() at that time.
The 'Print Job Thread' thread checks jobDone flag after exiting the synchronized block and, if it is true, skips the last page.

In this fix, not only the jobDone is checked, but also that there is no other page to be printed.
It was also needed to introduce a new flag 'jobCanceled', to skip the page if the printing was canceled by 'cancelJob()'.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/916/head:pull/916
$ git checkout pull/916

Update a local copy of the PR:
$ git checkout pull/916
$ git pull https://git.openjdk.org/jfx pull/916/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 916

View PR using the GUI difftool:
$ git pr show -t 916

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/916.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 14, 2022

👋 Welcome back eduardsdv! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Oct 14, 2022
@mlbridge
Copy link

mlbridge bot commented Oct 14, 2022

Webrevs

@kevinrushforth
Copy link
Member

/reviewers 2

@openjdk
Copy link

openjdk bot commented Oct 14, 2022

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@eduardsdv
Copy link
Contributor Author

Please review

@eduardsdv
Copy link
Contributor Author

It seems that not all errors were fixed with this PR. Yesterday, a blank page was printed again. I will analyze what this can be due to.

The test now also checks for the second race condition around 'jobDone'
flag, which is in the print(Graphics, PageFormat, int) method.
This occurs in print(Graphics, PageFormat, int) if the 'jobDone' flag
was previously set by the 'endJob()' method.
@eduardsdv
Copy link
Contributor Author

I found the second place with the race condition. It was in the print(Graphics g, PageFormat pf, int pageIndex) method.
Also here "jobDone" was checked without checking if a page was pending.

Please review.

@kevinrushforth
Copy link
Member

@prrace Can you review this?

@eduardsdv
Copy link
Contributor Author

eduardsdv commented Nov 22, 2022

Can someone else check this PR if @prrace is not available?

@prrace
Copy link
Collaborator

prrace commented Nov 30, 2022

I think this is OK, but whilst I can see you went to some lengths to create a test case, I do not think it justifies
the refactoring you had to do in order to create the test program.
So I'd prefer that ALL refactoring be reverted, even if it means no test program.

@eduardsdv
Copy link
Contributor Author

Ok. I have reverted all changes regarding refactoring and testing.

@openjdk
Copy link

openjdk bot commented Dec 5, 2022

@eduardsdv 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:

8295324: JavaFX: Blank pages when printing

Reviewed-by: prr, kcr

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 43 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

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 (@prrace, @kevinrushforth) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Ready to be integrated label Dec 5, 2022
@eduardsdv
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Ready to sponsor label Dec 6, 2022
@openjdk
Copy link

openjdk bot commented Dec 6, 2022

@eduardsdv
Your change (at version 127cb03) is now ready to be sponsored by a Committer.

@kevinrushforth
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 6, 2022

Going to push as commit 7b3c88b.
Since your change was applied there have been 43 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 6, 2022
@openjdk openjdk bot closed this Dec 6, 2022
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review sponsor Ready to sponsor labels Dec 6, 2022
@openjdk
Copy link

openjdk bot commented Dec 6, 2022

@kevinrushforth @eduardsdv Pushed as commit 7b3c88b.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants