engine icon indicating copy to clipboard operation
engine copied to clipboard

Expose macOS -[FlutterViewController initWithEngine:::] in header

Open jmagman opened this issue 2 years ago • 5 comments

To support macOS add-to-app, move initWithEngine: into header so the host app can run the warm up the engine and pass it into a view controller later to display the Flutter views.

This will match the iOS pattern documented in https://docs.flutter.dev/development/add-to-app/ios/add-flutter-screen?tab=engine-swift-tab#show-a-flutterviewcontroller-with-your-flutterengine

Fixes https://github.com/flutter/flutter/issues/105347

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I signed the CLA.
  • [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

jmagman avatar Jun 13 '22 22:06 jmagman

I haven't had a chance to look yet (I'm OOO today) but I'm pretty sure anyone trying to do what the PR describes enabling will hit https://github.com/flutter/flutter/issues/74735

So we should probably fix that first.

stuartmorgan avatar Jun 16 '22 16:06 stuartmorgan

I noticed that initWithEngine calls setViewController on the engine, but setViewController will get called again by launchEngine

This causes the view not to show, because the viewController has not allocated its flutterView yet, so that's what is passed to the renderer and is never reassigned. I think the proper fix would be to remove the setViewController call from initWithEngine?

awood314 avatar Jun 16 '22 23:06 awood314

Sorry; I never linked back here when I commented on the other issue. See notes here: https://github.com/flutter/flutter/issues/74735#issuecomment-1157931202

cbracken avatar Jun 21 '22 18:06 cbracken

This looks blocked. Is that right @jmagman & @cbracken ?

chinmaygarde avatar Jun 23 '22 20:06 chinmaygarde

We'll want to fix https://github.com/flutter/flutter/issues/74735 first, yes. Added some notes on that bug the other day. Marked as WIP to get it off your PR triage list till then.

cbracken avatar Jun 23 '22 21:06 cbracken

@jmagman What's the status of this PR?

Hixie avatar Sep 27 '22 23:09 Hixie

Closing in favor of https://github.com/flutter/engine/pull/36410

jmagman avatar Sep 27 '22 23:09 jmagman