Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dkwingsmt
Copy link
Contributor

This PR makes the macOS FlutterCompositor able to handle multiple views by adding methods AddView and RemoveView.

These two methods must take place on the main queue (platform thread), which is indeed the case, but extra effort is made to assert so. This is important because, due to the constraint of the macOS system that requires rendering to take place on the platform thread (hence FlutterThreadSynchronizer), no locks are needed to avoid race condition between Add/RemoveView and presenting.

Pre-launch Checklist

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

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

@dkwingsmt
Copy link
Contributor Author

Also cc @loic-sharma

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but please get approval from someone familiar with this area

return [self viewControllerForIdentifier:kFlutterImplicitViewId];
}

- (FlutterCompositor*)createFlutterCompositor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still the right name for the method? "Create" usually implies allocation of some sort. Here what we're doing is more like initialisation the existing field and returning a pointer to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's still a reasonable name. For whoever uses FlutterEngine, this method creates a embedderAPI/FlutterCompositor object and returns it. How the object is memory-managed is implementation detail.

FlutterTimeConverter* time_converter,
FlutterPlatformViewController* platform_views_controller);
FlutterPlatformViewController* platform_views_controller,
dispatch_queue_t main_queue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a case where this isn't the main queue returned by dispatch_get_main_queue()? If not, I think we should just test dispatch_get_current_queue() == dispatch_get_main_queue() where necessary.

Copy link
Contributor Author

@dkwingsmt dkwingsmt Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm mostly thinking about testability, although there really aren't many tests for FlutterCompositor. However, the ThreadSynchronizer accepts the queue as a replaceable parameter (which was added when I wrote tests for it). I think it's a clearer design if the same queue is passed in for both classes in production code.

Copy link
Contributor Author

@dkwingsmt dkwingsmt Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, ThreadSynchronizer has two initializers, one of which uses the main queue implicitly, which is used in production code. Still, its internal implementation allows a replaceable queue. I'm ok with any suggestion.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly lgtm - main question is why we need to pass in the dispatch queue.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM stamp from a Japanese personal seal

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2024
@auto-submit auto-submit bot merged commit b369582 into flutter:main Jul 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 11, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 11, 2024
flutter/engine@1c23c8f...6534fbf

2024-07-10 58529443+srujzs@users.noreply.github.com Remove casts for toDartObject (flutter/engine#53621)
2024-07-10 dkwingsmt@users.noreply.github.com [macOS] Multiview compositor (flutter/engine#52253)
2024-07-10 skia-flutter-autoroll@skia.org Roll Dart SDK from dba0dfbd06eb to c6053ad84f2b (3 revisions) (flutter/engine#53798)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC bdero@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

affects: desktop autosubmit Merge PR when tree becomes green via auto submit App platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants