Skip to content

Custom task runners are difficult to use with FlutterEngineRun. #42460

@chinmaygarde

Description

@chinmaygarde

Currently, FlutterEngineRun initializes the engine and runs the root isolate. This has worked out fine so far. However, as fix for #17579 (comment), there is a desire to expose more task runners for the embedder to control. Exposing task runners themselves is fairly straightforward. However, for embedders to post expired tasks back to the engine, they need a handle to the engine. This handle is only returned to the embedder after FlutterEngineRun returns. But FlutterEngineRun may have to wait for tasks to be serviced on another thread before it can return. So the engine will wait for the task to be posted on another thread before returning from FlutterEngineRun while the embedder will wait on FlutterEngineRun to return so it can get a handle to the engine to for it to post the expired task. This causes a deadlock.

The proposed solution is the create two new embedder API calls. These are FlutterEngineInitialize and FlutterEngineRunInitialized respectively. The first will create an engine but not bootstrap its shell or run any root isolates. Using this minimal setup, the embedder can get a hold of the engine handle. It can then make the second call and avoid the deadlock scenario described above.

The existing call stays as is. It works well enough for embedders not performing complicated task runner configuration.

Metadata

Metadata

Assignees

Labels

e: embedderUsers of the Embedder API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions