-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: desktopRunning on desktopRunning on desktopa: pluginsSupport for writing, building, and running plugin packagesSupport for writing, building, and running plugin packagesc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.good first issueRelatively approachable for first-time contributorsRelatively approachable for first-time contributorsplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamOwned by the Windows platform teamtriaged-windowsTriaged by the Windows platform teamTriaged by the Windows platform team
Description
There are plugin APIs that can only be called from the main thread, but there's not a particularly good way for Windows plugins to move calls to that thread AFAIK. Options include:
- Each plugin doing the hidden-window message loop implementation themselves.
- Using the top-level window proc override registration to send themselves a custom message and hope nobody else uses it in a way that interferes.
This came up in the Texture PR and the solution there was to make most of it thread-safe; applying that more broadly is another option (e.g., to event streams). But a generic way to move things to the main thread would avoid needing to make lots of thread-safe APIs.
Proposed API:
class FlutterEngine : public PluginRegistry {
// ...
// Schedule a callback to be called on the platform thread.
//
// This may be called on any thread. The callback is executed only
// once on the platform thread.
void PostPlatformThreadTask(std::function<void()> callback);
}// Schedule a callback to be invoked on the engine's platform thread.
//
// This may be called on any thread. The callback is executed only
// once on the platform thread.
FLUTTER_EXPORT void FlutterDesktopEnginePostPlatformThreadTask(
FlutterDesktopEngineRef engine,
VoidCallback callback,
void* user_data);/cc @cbracken
(We would only do one of #134346 and this.)
Sunbreak, bernaferrari, Piero512, liugangnhm, sebastianhaberey and 10 more
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: desktopRunning on desktopRunning on desktopa: pluginsSupport for writing, building, and running plugin packagesSupport for writing, building, and running plugin packagesc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.good first issueRelatively approachable for first-time contributorsRelatively approachable for first-time contributorsplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamOwned by the Windows platform teamtriaged-windowsTriaged by the Windows platform teamTriaged by the Windows platform team