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 all commits
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,6 +80,7 @@ - (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;
}

@@ -89,6 +90,7 @@ - (void) blitTexture {
@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 +101,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 +282,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;
}