Hi, I'm Tony working with @stevenbrix and others at The Browser Company and am interested in understanding the proposal better and figuring out some near-term ways to work towards a solution.
Our scenario is that we use Chromium's message pump on Windows for our main UI thread, which in addition to dispatching its own tasks has battle-tested logic for managing lots of edge cases involving input.
The scenario is similar to Android, as @Geordie_J has talked about, so I understand that our custom executor's run
method would synchronously call our hostedChromium.run()
, which is then responsible for processing everything on the main thread until it's told to stop.
Given this, I see two core requirements:
- A way of knowing that there's pending work that only the RunLoop knows how to process.
- A way to process the pending work in the RunLoop without the risk of it blocking, and without side-effects such as dispatching input messages or throwing away messages it doesn't know about.
Currently we're using heuristics for #1 and limitDate
for #2.
There's an immediate need and I've been investigating all the way down into dispatch!_dispatch_runloop_queue_class_poke
, to see what's available to hook off of in a clean, performant way and provide an event/callback off of Foundation
that piggybacks on this or similar.
Additionally, for the idea of introducing an API similar to limitDate
that doesn't generically call TranslateMessage/DispatchMessage
on Windows, I noticed in CFRunLoop.c
there's rlm->_msgPump()
, set by _CFRunLoopSetWindowsMessageQueueHandler
, though it doesn't seem to be used and for our purposes it seems fine just to leave messages in the queue.
Since I believe these two things are needed, and I'm sure people in this thread have ideas about the implementation and shape of the APIs, I'd like to better understand what we can do now to unblock work and then become an early adopter of the long-term solution. Several people on the team already actively contribute to the Swift toolchain, so we're up for making the changes and getting them vetted.