In stress based scenarios it is observed that nothing is drawn in UI content 
when display wakes up from sleep in Metal pipeline of macOS. Unfortunately i am 
not able to reproduce it, but based on details in the bug it looks like we are 
hitting a race condition. Call to CVDisplayLinkCreateWithActiveCGDisplays is 
becoming a no-op as there are no active displays right after 
NSWorkspaceScreensDidWakeNotification. Looks like if we continue to call 
CVDisplayLinkCreateWithActiveCGDisplays after screen wakeup we are able to get 
the list of ActiveDisplays and then able to create displayLink.

So now the code is modified to check whether 
CVDisplayLinkCreateWithActiveCGDisplays is successful or not. If not we will 
try to call CVDisplayLinkCreateWithActiveCGDisplays for 5 instances each with 1 
second delay. There is no regression test for this change because it needs a 
stress based test with display wakeup/sleep(As captured in JBS, i am not able 
to reproduce this issue).

I have tested this change for sanity by running animation examples from 
SwingSet2 and continuously connecting/disconnecting external display. Also by 
multiple display sleep and wakeup scenarios, i don't see any regressions. Also 
whole clientlibs CI run is done with this patch and it is also green.

While working on this bug also noticed that many functions of CVDisplayLink is 
deprecated from macOS 14 and going forward we need to use 
CADisplayLink/CAMetalDisplayLink. I have raised 
[JDK-8357418](https://bugs.openjdk.org/browse/JDK-8357418) for the same.

-------------

Commit messages:
 - 8312198: [macos] metal pipeline - window rendering stops after display sleep

Changes: https://git.openjdk.org/jdk/pull/25342/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25342&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8312198
  Stats: 22 lines in 2 files changed: 19 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/25342.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25342/head:pull/25342

PR: https://git.openjdk.org/jdk/pull/25342

Reply via email to