-
Notifications
You must be signed in to change notification settings - Fork 6k
Support custom entrypoints in public Windows API #35285
Conversation
I'd be particularly interested in @knopp's review here as the author of an alternative embedder. There are ways we could do this and fully preserve backward compatibility, though it likely involves coming up with some relatively unfortunate function names (particularly the no-entrypoint variant of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, but I'm conflicted on the breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked offline, breaking changes shouldn't affect the vast majority of apps. We think the impact is acceptable.
LGTM
c6ac110
to
711a093
Compare
711a093
to
2c45fa1
Compare
Alright -- did some refactoring to avoid breaking backward-compatibility for windows embedder wrappers. Thanks for pushing back on this; the resulting patch I think gets us to a place where flutter/flutter#93537 is fixed and we have the fixture testing I wanted, plus preserves backward compatibility. We can deal with the more contentious issue of how we deprecate the entrypoint parameter on |
This adds a dart_entrypoint field to FlutterDesktopEngineProperties in the public C Windows API, which mirrors that in the embedder API. When a null or empty entrypoint is specified, a default entrypoint of 'main' is assumed. Otherwise, the app is launched at the top-level function specified, which must be annotated with @pragma('vm:entry-point') in the Dart source. To avoid breaking backward compatibility, this patch preserves the entry_point parameter to FlutterDesktopEngineRun in the public Windows C API as well as in the FlutterEngine::Run method. The entrypoint can be specified in either place, but if conflicting non-empty values are specified, the engine launch will intentionally fail with an error message. Fixes: flutter/flutter#93537 Related: flutter/flutter#87299
2c45fa1
to
cccaee1
Compare
// | ||
// If provided, entry_point must be the name of a top-level function from the | ||
// If sprecified, entry_point must be the name of a top-level function from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If sprecified, entry_point must be the name of a top-level function from the | |
// If specified, entry_point must be the name of a top-level function from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-LGTM. Looks great! 🎉
This adds a dart_entrypoint field to FlutterDesktopEngineProperties in the public C Windows API, which mirrors that in the embedder API. When a null or empty entrypoint is specified, a default entrypoint of 'main' is assumed. Otherwise, the app is launched at the top-level function specified, which must be annotated with @pragma('vm:entry-point') in the Dart source. This change is backward-compatible for existing users of the Windows C API and the C++ client wrapper API. To avoid breaking backward compatibility, this patch preserves the entry_point parameter to FlutterDesktopEngineRun in the public Windows C API as well as in the FlutterEngine::Run method in the C++ client wrapper API. The entrypoint can be specified in either the engine properties struct or via the parameter, but if conflicting non-empty values are specified, the engine launch will intentionally fail with an error message. This change has no effect on existing Flutter Windows desktop apps and no migration is required, because our app templates never specify a custom entrypoint, nor was the option to specify one via the old method particularly feasible, because the FlutterViewController class constructor immediately invokes FlutterViewControllerCreate which immediately launches the engine passed to it with a null entrypoint argument, so long as the engine is not already running. However, running the engine without a view controller previously resulted in errors due to failure to create a rendering surface. This is a followup patch to flutter#35273 which added support for running Dart fixture tests with a live Windows embedder engine. Fixes: flutter/flutter#93537 Related: flutter/flutter#87299
This adds a
dart_entrypoint
field toFlutterDesktopEngineProperties
inthe public C Windows API, which mirrors that in the embedder API.
When a null or empty entrypoint is specified, a default entrypoint of
'main' is assumed. Otherwise, the app is launched at the top-level
function specified, which must be annotated with
@pragma('vm:entry-point')
in the Dart source.This change is backward-compatible for existing users of the Windows C API
and the C++ client wrapper API. To avoid breaking backward compatibility,
this patch preserves the
entry_point
parameter toFlutterDesktopEngineRun
in the public Windows C API as well as in the
FlutterEngine::Run
methodin the C++ client wrapper API. The entrypoint can be specified in either
the engine properties struct or via the parameter, but if conflicting
non-empty values are specified, the engine launch will intentionally fail
with an error message.
This change has no effect on existing Flutter Windows desktop apps and no
migration is required, because our app templates never specify a custom
entrypoint, nor was the option to specify one via the old method
particularly feasible, because the
FlutterViewController
class constructorimmediately invokes
FlutterViewControllerCreate
whichimmediately launches the engine passed to it with a null entrypoint
argument, so long as the engine is not already running. However, running the
engine without a view controller previously resulted in errors due to failure to
create a rendering surface.
This is a followup patch to #35273
which added support for running Dart fixture tests with a live Windows
embedder engine.
Fixes: flutter/flutter#93537
Related: flutter/flutter#87299
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.