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

8264786: [macos] All Swing/AWT apps cause Allow Notifications prompt to appear when app is launched #3707

Closed
wants to merge 1 commit into from

Conversation

@mrserb
Copy link
Member

@mrserb mrserb commented Apr 27, 2021

The fix for the JDK-8187639 reimplemented the tray icon messages using the standard notification center, it worked fine on macOS 10.9. But on the new macOS, the usage of that API requests permission from the user. Since the code was added to the NSApplicationAWT this request is always shown even if the app does not use tray icons. This fix moves the code to the tray icon itself. I have tested this on macOS 11.2. It will be good if someone can check macOS 10.14 or macOS 10.15.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8264786: [macos] All Swing/AWT apps cause Allow Notifications prompt to appear when app is launched

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3707/head:pull/3707
$ git checkout pull/3707

Update a local copy of the PR:
$ git checkout pull/3707
$ git pull https://git.openjdk.java.net/jdk pull/3707/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3707

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3707.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Apr 27, 2021

👋 Welcome back serb! 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
Copy link

@openjdk openjdk bot commented Apr 27, 2021

@mrserb The following label will be automatically applied to this pull request:

  • awt

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the awt label Apr 27, 2021
@mrserb mrserb marked this pull request as ready for review Apr 27, 2021
@openjdk openjdk bot added the rfr label Apr 27, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 27, 2021

Webrevs

@victordyakov
Copy link

@victordyakov victordyakov commented Apr 28, 2021

@prrace @prsadhuk @azvegint Please review

Copy link
Member

@azvegint azvegint left a comment

I've checked it on 10.15.7.
before the fix - permission request appears immediately.
after the fix - permission request appears after using TrayIcon.

@openjdk
Copy link

@openjdk openjdk bot commented Apr 28, 2021

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

8264786: [macos] All Swing/AWT apps cause Allow Notifications prompt to appear when app is launched

Reviewed-by: azvegint, kizune

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

  • 5c083e8: 8266129: tools/jpackage/windows/WinInstallerIconTest.java hangs with fastdebug
  • 3e667cc: 8265356: need code example for getting canonical constructor of a Record
  • f86b70c: 8266328: C2: Remove InlineWarmCalls
  • 928d632: 8252237: C2: Call to compute_separating_interferences has wrong argument order
  • 50fa162: 8266389: ProblemList java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java on generic-all
  • dd05158: 8266155: Convert java.base to use Stream.toList()
  • c36c63a: 8260560: convert jdeps and jdeprscan tools to use Stream.toList()
  • 096e9e5: 8266318: Switch to macos prefix for macOS bundles
  • 0544a73: 8255227: java/net/httpclient/FlowAdapterPublisherTest.java intermittently failing with TestServer: start exception: java.io.IOException: Invalid preface
  • 48bb996: 8266220: keytool still prompt for store password on a password-less pkcs12 file if -storetype pkcs12 is specified
  • ... and 138 more: https://git.openjdk.java.net/jdk/compare/f6e22d14e3ee529f21ab8747cfbafe72b906ec68...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Apr 28, 2021
@victordyakov
Copy link

@victordyakov victordyakov commented Apr 29, 2021

@prsadhuk please review

@prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented May 1, 2021

Please confirm if it is working in 10.14 and in multiscreen environment. Also, I guess a testcase can be written to see if notification center is coming up for normal awt non-trayicon app(obscuring normal awt window or not)

BTW, I see from https://developer.apple.com/documentation/foundation/nsusernotificationcenter?language=objc
that this class is deprecated, so I think we should not use this way of notifying user and find some other alternative or do away with this or else we will get new problems like this in newer releases.

I think we should use https://developer.apple.com/documentation/usernotifications?language=objc "UNUserNotificationCenter" instead which is the favoured way since Mohave, it seems.

@mrserb
Copy link
Member Author

@mrserb mrserb commented May 2, 2021

Please confirm if it is working in 10.14 and in multiscreen environment. Also, I guess a testcase can be written to see if notification center is coming up for normal awt non-trayicon app(obscuring normal awt window or not)

I cannot confirm that it works on 10.14 since I do not have such a system, this is why in the description of this PR I requested to check the fix by someone on 10.14/10.15. Thanks to Alexander who confirm it on 10.15.

To test this functionality the user will need to enable the notification center, which should be disabled by default for the execution of our tests, then checks that the "Do not disturb" is not set for the current time, remove the java from the allow/disallow list. And then the user should return all that back. If some step will be skipped it will affect the tests executed after. I prefer do not to request that.

BTW, I see from https://developer.apple.com/documentation/foundation/nsusernotificationcenter?language=objc
that this class is deprecated, so I think we should not use this way of notifying user and find some other alternative or do away with this or else we will get new problems like this in newer releases.

I know, this information is already in the jbs. When we will move further from the macOS10.14 in our JDK trains we probably should migrate to the new API.

@mrserb
Copy link
Member Author

@mrserb mrserb commented May 3, 2021

/integrate

@openjdk openjdk bot closed this May 3, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels May 3, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 3, 2021

@mrserb Since your change was applied there have been 163 commits pushed to the master branch:

  • 45760d4: 8266320: (bf) ReadOnlyBufferException in heap buffer put(String,int,int) should not be conditional
  • ff65920: 8265491: Math Signum optimization for x86
  • 55cc0af: 8266185: Shenandoah: Fix incorrect comment/assertion messages
  • 880c138: 8265349: vmTestbase/../stress/compiler/deoptimize/Test.java fails with OOME due to CodeCache exhaustion.
  • 001c514: 8265322: C2: Simplify control inputs for BarrierSetC2::obj_allocate
  • 194bcec: 8265984: Concurrent GC: Some tests fail "assert(is_frame_safe(f)) failed: Frame must be safe"
  • 1d9ea3a: 8266083: Shenandoah: Consolidate dedup/no dedup oop closures
  • 80941f4: 8234446: Post-CMS workgroup hierarchy cleanup
  • ac760c7: 8266295: Remove unused _concurrent_iteration_safe_limit
  • b42d496: 8266388: C2: Improve constant ShiftCntV on x86
  • ... and 153 more: https://git.openjdk.java.net/jdk/compare/f6e22d14e3ee529f21ab8747cfbafe72b906ec68...master

Your commit was automatically rebased without conflicts.

Pushed as commit 020236c.

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

@mrserb mrserb deleted the JDK-8264786 branch May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants