Skip to content

Commit 87fdd55

Browse files
committed
Address feedback
1 parent 7f155d7 commit 87fdd55

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

skiko/src/awtMain/objectiveC/macos/DisplayLinkThrottler.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,19 @@ - (instancetype)initWithWindow:(NSWindow *)window {
9292
[self onScreenDidChange];
9393
} else {
9494
// In case of OpenJDK, EDT thread != NSThread main thread
95+
// There is one thing we should keep in mind. Postponing creation of vsync throttler will cause that for sometime there won't be any waiting:
96+
//
97+
// ```
98+
// create window
99+
// (10x) schedule render -> render
100+
// onScreenDidChange
101+
// schedule render -> wait vsync -> render
102+
// ```
103+
//
104+
// It is probably okay, but possible alternative would be to wait for throttler creation. It is difficult, so we can just keep the current code.
105+
__weak DisplayLinkThrottler *weakSelf = self;
95106
dispatch_async(dispatch_get_main_queue(), ^{
96-
[self onScreenDidChange];
107+
[weakSelf onScreenDidChange];
97108
});
98109
}
99110
}

skiko/src/awtMain/objectiveC/macos/MetalRedrawer.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ static void setWindowProperties(NSWindow* window, jboolean transparency) {
127127
setWindowPropertiesUnsafe(window, transparency);
128128
} else {
129129
// In case of OpenJDK, EDT thread != NSThread main thread
130+
__weak NSWindow *weakWindow = window;
130131
dispatch_sync(dispatch_get_main_queue(), ^{
131-
setWindowPropertiesUnsafe(window, transparency);
132+
setWindowPropertiesUnsafe(weakWindow, transparency);
132133
});
133134
}
134135
}

0 commit comments

Comments
 (0)