From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, John Arbuckle <programmingkidx@gmail.com>,
Berkus Decker <berkus@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Roman Bolshakov <r.bolshakov@yadro.com>
Subject: [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop
Date: Sat, 1 Dec 2018 12:30:51 +0000 [thread overview]
Message-ID: <20181201123056.432-1-peter.maydell@linaro.org> (raw)
This set of patches rearranges how we handle events on
the OSX Cocoa UI so that we use the main thread to run
the OSX event loop, and we don't do a long blocking
operation from the applicationDidFinishLaunching callback.
Instead we create a second thread which runs qemu_main()
and becomes the QEMU main-loop thread. The callbacks from
QEMU into the cocoa code asynchronously dispatch their
work to the main thread, and the main thread takes the
iothread lock before calling into QEMU code.
This code all works (though I have only smoke-tested it),
but it is marked RFC because it seems to be unclear whether
the current code in git master is really problematic for
Mojave. If it's not actually solving a problem then it's
a bit tricky to justify this rework, though it does mean
we're doing a less "weird" set of things and behaving a bit
more like how OSX expects apps to behave, so it might in
theory mean less chance of future breakage.
NB: the code to asynchronously run code blocks on the
main thread uses dispatch_get_main_queue(), which is a
10.10-or-later function. If we're going to go with this
refactoring I think the benefit in clarity-of-code is a
worthwhile gain for dropping support for ancient OSX versions.
Patchset structure:
* patch 1 does the "make sure we have the iothread lock for
calls into QEMU" (which is effectively a no-op initially
since we'll already be holding that lock when our refresh
etc callbacks are called)
* patch 2 makes switchSurface directly take the pixman image
(which is refcounted) rather than the DisplaySurface (which
is not), so we can make the calls to it asynchronous later
* patches 3 and 4 are just trivial code motion
* patch 5 does the bulk of the work (and can't really be split
further without the UI being broken at the intermediate point)
thanks
-- PMM
Peter Maydell (5):
ui/cocoa: Ensure we have the iothread lock when calling into QEMU
ui/cocoa: Use the pixman image directly in switchSurface
ui/cocoa: Factor out initial menu creation
ui/cocoa: Move console/device menu creation code up in file
ui/cocoa: Perform UI operations only on the main thread
ui/cocoa.m | 441 +++++++++++++++++++++++++++++++----------------------
1 file changed, 258 insertions(+), 183 deletions(-)
--
2.19.2
next reply other threads:[~2018-12-01 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 12:30 Peter Maydell [this message]
2018-12-01 12:30 ` [Qemu-devel] [RFC 1/5] ui/cocoa: Ensure we have the iothread lock when calling into QEMU Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 2/5] ui/cocoa: Use the pixman image directly in switchSurface Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 3/5] ui/cocoa: Factor out initial menu creation Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 4/5] ui/cocoa: Move console/device menu creation code up in file Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 5/5] ui/cocoa: Perform UI operations only on the main thread Peter Maydell
2018-12-03 15:47 ` [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop Richard Henderson
2018-12-05 6:51 ` Gerd Hoffmann
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=20181201123056.432-1-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=berkus@gmail.com \
--cc=kraxel@redhat.com \
--cc=patches@linaro.org \
--cc=programmingkidx@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
/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).