9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Xiao-Yong Jin <meta.jxy@gmail.com>
To: 9front@9front.org
Subject: [9front] drawterm gui-cocoa/screen.m display() needs a drawlock
Date: Mon, 22 Jan 2024 18:19:09 -0600	[thread overview]
Message-ID: <62F053FB-B410-4ADA-A066-B2DD1DD70A6D@gmail.com> (raw)

If a screen resize happens between blit command encoding and command
buffer execution, drawterm will crash, because the encoded _texture
gets replaced by screensize() and no longer points to valid memory.
The following patch adds the drawlock to keep _texture consistent.

% diff -u gui-metal/screen.m gui-cocoa/screen.m
--- a/gui-cocoa/screen.m 2024-01-22 17:59:15
+++ b/gui-cocoa/screen.m 2023-08-22 00:20:02
@@ -937,9 +931,6 @@
 	}
 	
 	blit = [cbuf blitCommandEncoder];
+
+	qlock(&drawlock);
+
 	[blit copyFromTexture:_texture
 		sourceSlice:0
 		sourceLevel:0
@@ -961,7 +952,6 @@
 		}else{
 			LOG(@"command buffer finished");
 		}
+		qunlock(&drawlock);
 	}];
 	[cbuf commit];
 }


                 reply	other threads:[~2024-01-23  0:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62F053FB-B410-4ADA-A066-B2DD1DD70A6D@gmail.com \
    --to=meta.jxy@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).