Skip to content
This repository has been archived by the owner. It is now read-only.

8267602: [macos] [lanai] java/awt/PrintJob/Text/stringwidth.sh doesn't exit on cancelling print dialog #175

Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
@@ -80,15 +80,18 @@ - (id) initWithJavaLayer:(jobject)layer
- (void) blitTexture {
if (self.ctx == NULL || self.javaLayer == NULL || self.buffer == nil || self.ctx.device == nil) {
J2dTraceLn4(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: uninitialized (mtlc=%p, javaLayer=%p, buffer=%p, devide=%p)", self.ctx, self.javaLayer, self.buffer, ctx.device);
[self stopDisplayLink];
return;
}

if (self.nextDrawableCount != 0) {
[self stopDisplayLink];
This conversation was marked as resolved by jayathirthrao

This comment has been minimized.

Loading
@aghaisas

aghaisas Jun 30, 2021
Contributor Outdated

Please check invoking stopDisplayLink at this place. If a Drawable is not available, we should return from here but recheck after 16ms. A drawable might be made available on subsequent attempts.

Stopping DisplayLink at other invalid cases makes sense.

This comment has been minimized.

Loading
@jayathirthrao

jayathirthrao Jun 30, 2021
Author Member Outdated

@aghaisas Thanks for the review. Redraw of static content is driven by setNeedsDisplay, because we stop CVDisplayLink once final blit is done. Also with preliminary testing i see that we are not hitting this condition at all after CVDisplayLink is enabled. We still have a verification task under https://bugs.openjdk.java.net/browse/JDK-8258583 . Stopping or not stopping CVDisplayLink at this place is not causing any change. I will go ahead and remove stopDisplayLink at this place, in future if we hit this code because of some boundary condition we can enable it and verify.

return;
}
@autoreleasepool {
if ((self.buffer.width == 0) || (self.buffer.height == 0)) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: cannot create drawable of size 0");
[self stopDisplayLink];
return;
}

@@ -99,17 +102,20 @@ - (void) blitTexture {

if (src_h <= 0 || src_w <= 0) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: Invalid src width or height.");
[self stopDisplayLink];
return;
}

id<MTLCommandBuffer> commandBuf = [self.ctx createBlitCommandBuffer];
if (commandBuf == nil) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: commandBuf is null");
[self stopDisplayLink];
return;
}
id<CAMetalDrawable> mtlDrawable = [self nextDrawable];
if (mtlDrawable == nil) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: nextDrawable is null)");
[self stopDisplayLink];
return;
}
self.nextDrawableCount++;
@@ -277,6 +283,7 @@ CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* no
MTLContext * ctx = layer.ctx;
if (layer == NULL || ctx == NULL) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer_blit : Layer or Context is null");
[layer stopDisplayLink];
This conversation was marked as resolved by jayathirthrao

This comment has been minimized.

Loading
@mrserb

mrserb Jun 29, 2021
Member

What happens if we exit before this "blitTexture" is called? Do not we need to stop(w/o possibility to restart it) that thread on toolkit shutdown or something like this?

This comment has been minimized.

Loading
@jayathirthrao

jayathirthrao Jun 30, 2021
Author Member

At this point if we exit, we just return and unlock MTLRenderQueue for backbuffer rendering. And when it is done we again start CVDisplayLink in MTLRenderQueue which in turn calls setNeedsDisplay to get callback to MTLLayer.display().

This scenario is same as returning from CGLLayer.blitTexture() when textureID is 0. Appkit thread will be running in the background and we dont stop it.

This comment has been minimized.

Loading
@mrserb

mrserb Jun 30, 2021
Member

No, I meant if we dispose the frame/exist from the app/etc before "Java_sun_java2d_metal_MTLLayer_blitTexture" method is executed but after we call "startDisplayLink", when we will call the stopDisplayLink in this case?

This comment has been minimized.

Loading
@jayathirthrao

jayathirthrao Jun 30, 2021
Author Member

In that case it will hit MTLLayer.dealloc() where we stop and release CVDisplayLink.

This comment has been minimized.

Loading
@jayathirthrao

jayathirthrao Jun 30, 2021
Author Member

@mrserb Please let me know if i can resolve this conversation.

This comment has been minimized.

Loading
@mrserb

mrserb Jun 30, 2021
Member

ok, looks fine

return;
}