RFR: 8312198: [macos] metal pipeline - window rendering stops after display sleep [v2]

Jayathirth D V jdv at openjdk.org
Fri May 23 11:48:51 UTC 2025


On Thu, 22 May 2025 08:07:34 GMT, Alexey Ushakov <avu at openjdk.org> wrote:

>> Jayathirth D V has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add macro
>
> 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.

This timing issue is happening is very rare stress based scenario and we don't want to continuously query for active displays to create DisplayLink. Having a delay of 1 sec is to make sure we can create DisplayLink reliably. It's okay if there are no updates to UI in such scenario right after we wake up the screen from sleep.

> 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.

I added comment to explain 5 seconds count, but its better to use constant i have added the same.

All selectors will be queued into same thread run loops, i don't see any way where we will skip 5th count. To be extra cautious i have updated the check to `>=`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25342#discussion_r2104420999
PR Review Comment: https://git.openjdk.org/jdk/pull/25342#discussion_r2104421094


More information about the client-libs-dev mailing list