On Wed, 21 May 2025 06:11:18 GMT, Jayathirth D V <j...@openjdk.org> wrote:
> 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. Changes requested by avu (Committer). src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.m line 52: > 50: - (void) createDisplayLink { > 51: CVReturn r = CVDisplayLinkCreateWithActiveCGDisplays(&displayLink); > 52: if (r != kCVReturnSuccess) { We may still miss an update of the window for a noticeable time (depending on the application code) because DisplayLink will not work during the retry period. src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.m line 54: > 52: if (r != kCVReturnSuccess) { > 53: if (self.displayLinkFailCount == 5) { > 54: // We have tried for 5 seconds to create CVDisplayLink It would be better to move this magic number to the beginning of the file as a verbose constant. Also, for reliability reasons, I would prefer the `>=` check here. ------------- PR Review: https://git.openjdk.org/jdk/pull/25342#pullrequestreview-2860218856 PR Review Comment: https://git.openjdk.org/jdk/pull/25342#discussion_r2101917612 PR Review Comment: https://git.openjdk.org/jdk/pull/25342#discussion_r2101924670