-
Notifications
You must be signed in to change notification settings - Fork 6k
iOS: Migrate PlatformViewsController to Objective-C #56790
iOS: Migrate PlatformViewsController to Objective-C #56790
Conversation
| - (size_t)embeddedViewCount; | ||
|
|
||
| // TODO(cbracken): Delete. This is unused. | ||
| - (size_t)layerPoolSize; |
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.
I'll delete this in a followup. This is just to keep things consistent for now.
|
|
||
| @end | ||
|
|
||
| @interface FlutterPlatformViewsController (Testing) |
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 we feel like, we could move this to a separate header, but this header is already internal so not particularly necessary/urgent.
|
|
||
| // TODO(cbracken): Eliminate the use of globals. | ||
| // Becomes NO if Apple's API changes and blurred backdrop filters cannot be applied. | ||
| BOOL canApplyBlurBackdrop = YES; |
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.
This will go in a followup. It's unnecessary. It's ordered here because oddly enough, it helped minimise the diff.
| // | ||
| // The Slices are deleted by the PlatformViewsController.reset(). | ||
| @property(nonatomic, readonly) | ||
| std::unordered_map<int64_t, std::unique_ptr<flutter::EmbedderViewSlice>>& slices; |
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.
Here and a bunch below: notice that the properties here are declared as reference types (std::unordered_map&), which allows for self.slices[foo] = bar rather than the underlying ivar type std::unordered_map, in order to avoid self.slices returning a copy.
This however, requires (a) manually declaring the ivar and (b) manually writing the getter.
These should eventually be migrated to Obj-C types like NSMutableDictionary*.
|
@hellohuanlin Looks like renaming the file made the diff 100% diff instead of clear. Here's the version without the rename where you can see the diffs clearly: |
hellohuanlin
left a comment
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.
Will continue the review in https://github.com/flutter/engine/pull/56766/files
This migrates PlatformViewController from C++ to Objective-C. Generally, we try to keep the embedder interfaces and components written in Objective-C except for the few places where C++ interfaces are requried to interface with engine APIs such as Shell and PlatformView (e.g. the PlatformViewIOS subclass). Now that the implementation is Objective-C, the class and file are renamed to match Objective-C naming conventions. This allows us to take advantage of ARC and weak references, which eliminates the need for std::shared_ptr, fml::WeakPtr etc. Further, this eliminates some particularly unintuitive behaviour wherein this class was owned via a std::shared_ptr held by FlutterEngine, and injected into many other classes (e.g. AccessibilityBridge) via a std::shared_ptr& reference -- such that only one instance of the std::shared_ptr actually ever existed, presumably to avoid std::shared_ptr refcounting overhead. Given that this overhead was only incurred a single time at engine initialisation, this seems like overkill. One might ask why it wasn't therefore held in a `std::unique_ptr` and a `std::unique_ptr&` reference passed around. Likely, this was because we wanted to take a `fml::WeakPtr` reference on it. Regardless, none of this is necessary any longer now that we can inject `__weak FlutterPlatformViewsController*` instances to classes that use it. To be clear, this patch makes no attempt whatsoever to simplify or clean up the interface or implementation of this class. This class ties together far too many concepts and is injected into far too many places, and we should break it up and simplify it. However, the goal of this patch was simply to port to an Objective-C interface that plays nicely with the rest of the iOS embedder. This does include a couple minor cleanups in `#include`/`#import` order and usage to match our style guide.
…159461) flutter/engine@fe45a66...fb64399 2024-11-26 [email protected] iOS: Migrate PlatformViewsController to Objective-C (flutter/engine#56790) 2024-11-26 [email protected] Started caching HandleGLES's hash and made them immutable (flutter/engine#56800) 2024-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[iOS] Full keyboard access scrolling (#56606)" (flutter/engine#56802) 2024-11-26 [email protected] Roll Skia from 12c8bd6ac1d9 to c1c8ff84997c (14 revisions) (flutter/engine#56801) 2024-11-25 [email protected] [Impeller] better handle allocation herustics of Android slide in page transition. (flutter/engine#56762) 2024-11-25 [email protected] iOS: Eliminate logging of non-zero origin platformviews (flutter/engine#56796) 2024-11-25 [email protected] [impeller] gles: started storing the number of handle deletions to avoid reallocation (flutter/engine#56799) 2024-11-25 [email protected] Roll Fuchsia Linux SDK from 9o0fWa2xVhmxV6Mtn... to 50xtjbMWWrqay_7m_... (flutter/engine#56795) 2024-11-25 [email protected] Roll Dart SDK from df716eaa6ed2 to 4b49546a1dfa (1 revision) (flutter/engine#56793) 2024-11-25 [email protected] [iOS] Full keyboard access scrolling (flutter/engine#56606) 2024-11-25 [email protected] [android] remove fml_check from surface_texture_external_texture (flutter/engine#56760) 2024-11-25 [email protected] removed unused variable for skia initialization (flutter/engine#56791) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 9o0fWa2xVhmx to 50xtjbMWWrqa 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 [email protected],[email protected] 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
…visions) (#159461)" (#159498) <!-- start_original_pr_link --> Reverts: #159461 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: yjbanov <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: engine regression #159497 <!-- end_revert_reason --> <!-- start_original_pr_author --> Original PR Author: engine-flutter-autoroll <!-- end_original_pr_author --> <!-- start_reviewers --> Reviewed By: {fluttergithubbot} <!-- end_reviewers --> <!-- start_revert_body --> This change reverts the following previous change: flutter/engine@fe45a66...fb64399 2024-11-26 [email protected] iOS: Migrate PlatformViewsController to Objective-C (flutter/engine#56790) 2024-11-26 [email protected] Started caching HandleGLES's hash and made them immutable (flutter/engine#56800) 2024-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[iOS] Full keyboard access scrolling (#56606)" (flutter/engine#56802) 2024-11-26 [email protected] Roll Skia from 12c8bd6ac1d9 to c1c8ff84997c (14 revisions) (flutter/engine#56801) 2024-11-25 [email protected] [Impeller] better handle allocation herustics of Android slide in page transition. (flutter/engine#56762) 2024-11-25 [email protected] iOS: Eliminate logging of non-zero origin platformviews (flutter/engine#56796) 2024-11-25 [email protected] [impeller] gles: started storing the number of handle deletions to avoid reallocation (flutter/engine#56799) 2024-11-25 [email protected] Roll Fuchsia Linux SDK from 9o0fWa2xVhmxV6Mtn... to 50xtjbMWWrqay_7m_... (flutter/engine#56795) 2024-11-25 [email protected] Roll Dart SDK from df716eaa6ed2 to 4b49546a1dfa (1 revision) (flutter/engine#56793) 2024-11-25 [email protected] [iOS] Full keyboard access scrolling (flutter/engine#56606) 2024-11-25 [email protected] [android] remove fml_check from surface_texture_external_texture (flutter/engine#56760) 2024-11-25 [email protected] removed unused variable for skia initialization (flutter/engine#56791) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 9o0fWa2xVhmx to 50xtjbMWWrqa 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 [email protected],[email protected] 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 <!-- end_revert_body --> Co-authored-by: auto-submit[bot] <[email protected]>
…#56817) This is a combination of 3 reverts, required to get back to the revert that caused `ios_platform_view_tests` to start failing in the framework repo. In reverse chronological order, this reverts two trivial commits plus the non-trivial commit that likely caused the breakage: * Revert "iOS: Eliminate global in platformviews controller (#56805)" This reverts commit 752e2d7. * Revert "iOS: Delete FlutterPlatformViewsController.layerPoolSize (#56806)" This reverts commit 21c655c. * Revert "iOS: Migrate PlatformViewsController to Objective-C (#56790)" This reverts commit fb64399. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…159504) flutter/engine@fe45a66...bd165dc 2024-11-26 [email protected] Revert "iOS: Migrate PlatformViewsController to Objective-C (#56790)" (flutter/engine#56817) 2024-11-26 [email protected] iOS: Rename FlutterPlatformViews_Internal.mm (flutter/engine#56816) 2024-11-26 [email protected] iOS: Eliminate global in platformviews controller (flutter/engine#56805) 2024-11-26 [email protected] Roll Skia from a276978ba7c8 to f149f852c70a (1 revision) (flutter/engine#56812) 2024-11-26 [email protected] Roll Skia from d7a267d88fd6 to a276978ba7c8 (1 revision) (flutter/engine#56811) 2024-11-26 [email protected] Roll Skia from 8d9d892657a7 to d7a267d88fd6 (1 revision) (flutter/engine#56810) 2024-11-26 [email protected] Roll Dart SDK from bdb76c714009 to ca02d403f1a8 (1 revision) (flutter/engine#56809) 2024-11-26 [email protected] Roll Skia from b697dd1b03b2 to 8d9d892657a7 (1 revision) (flutter/engine#56808) 2024-11-26 [email protected] Roll Skia from c1c8ff84997c to b697dd1b03b2 (1 revision) (flutter/engine#56807) 2024-11-26 [email protected] iOS: Delete FlutterPlatformViewsController.layerPoolSize (flutter/engine#56806) 2024-11-26 [email protected] Roll Dart SDK from 4b49546a1dfa to bdb76c714009 (1 revision) (flutter/engine#56803) 2024-11-26 [email protected] iOS: Migrate PlatformViewsController to Objective-C (flutter/engine#56790) 2024-11-26 [email protected] Started caching HandleGLES's hash and made them immutable (flutter/engine#56800) 2024-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[iOS] Full keyboard access scrolling (#56606)" (flutter/engine#56802) 2024-11-26 [email protected] Roll Skia from 12c8bd6ac1d9 to c1c8ff84997c (14 revisions) (flutter/engine#56801) 2024-11-25 [email protected] [Impeller] better handle allocation herustics of Android slide in page transition. (flutter/engine#56762) 2024-11-25 [email protected] iOS: Eliminate logging of non-zero origin platformviews (flutter/engine#56796) 2024-11-25 [email protected] [impeller] gles: started storing the number of handle deletions to avoid reallocation (flutter/engine#56799) 2024-11-25 [email protected] Roll Fuchsia Linux SDK from 9o0fWa2xVhmxV6Mtn... to 50xtjbMWWrqay_7m_... (flutter/engine#56795) 2024-11-25 [email protected] Roll Dart SDK from df716eaa6ed2 to 4b49546a1dfa (1 revision) (flutter/engine#56793) 2024-11-25 [email protected] [iOS] Full keyboard access scrolling (flutter/engine#56606) 2024-11-25 [email protected] [android] remove fml_check from surface_texture_external_texture (flutter/engine#56760) 2024-11-25 [email protected] removed unused variable for skia initialization (flutter/engine#56791) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 9o0fWa2xVhmx to 50xtjbMWWrqa 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 [email protected] 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
) This field is unused in the codebase/tests. This is a reland of #56806, which was reverted as part of #56790. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…6790) This migrates PlatformViewController from C++ to Objective-C. Generally, we try to keep the embedder interfaces and components written in Objective-C except for the few places where C++ interfaces are requried to interface with engine APIs such as Shell and PlatformView (e.g. the PlatformViewIOS subclass). Now that the implementation is Objective-C, the class and file are renamed to match Objective-C naming conventions. This allows us to take advantage of ARC and weak references, which eliminates the need for std::shared_ptr, fml::WeakPtr etc. Further, this eliminates some particularly unintuitive behaviour wherein this class was owned via a std::shared_ptr held by FlutterEngine, and injected into many other classes (e.g. AccessibilityBridge) via a std::shared_ptr& reference -- such that only one instance of the std::shared_ptr actually ever existed, presumably to avoid std::shared_ptr refcounting overhead. Given that this overhead was only incurred a single time at engine initialisation, this seems like overkill. One might ask why it wasn't therefore held in a `std::unique_ptr` and a `std::unique_ptr&` reference passed around. Likely, this was because we wanted to take a `fml::WeakPtr` reference on it. Regardless, none of this is necessary any longer now that we can inject `__weak FlutterPlatformViewsController*` instances to classes that use it. To be clear, this patch makes no attempt whatsoever to simplify or clean up the interface or implementation of this class. This class ties together far too many concepts and is injected into far too many places, and we should break it up and simplify it. However, the goal of this patch was simply to port to an Objective-C interface that plays nicely with the rest of the iOS embedder. This does include a couple minor cleanups in `#include`/`#import` order and usage to match our style guide. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…tter/engine#56830) This field is unused in the codebase/tests. This is a reland of flutter/engine#56806, which was reverted as part of flutter/engine#56790. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This migrates PlatformViewController from C++ to Objective-C. Generally, we try to keep the embedder interfaces and components written in Objective-C except for the few places where C++ interfaces are requried to interface with engine APIs such as Shell and PlatformView (e.g. the PlatformViewIOS subclass). Now that the implementation is Objective-C, the class and file are renamed to match Objective-C naming conventions.
This allows us to take advantage of ARC and weak references, which eliminates the need for std::shared_ptr, fml::WeakPtr etc. Further, this eliminates some particularly unintuitive behaviour wherein this class was owned via a std::shared_ptr held by FlutterEngine, and injected into many other classes (e.g. AccessibilityBridge) via a std::shared_ptr& reference -- such that only one instance of the std::shared_ptr actually ever existed, presumably to avoid std::shared_ptr refcounting overhead. Given that this overhead was only incurred a single time at engine initialisation, this seems like overkill. One might ask why it wasn't therefore held in a
std::unique_ptrand astd::unique_ptr&reference passed around. Likely, this was because we wanted to take afml::WeakPtrreference on it.Regardless, none of this is necessary any longer now that we can inject
__weak FlutterPlatformViewsController*instances to classes that use it.To be clear, this patch makes no attempt whatsoever to simplify or clean up the interface or implementation of this class. This class ties together far too many concepts and is injected into far too many places, and we should break it up and simplify it. However, the goal of this patch was simply to port to an Objective-C interface that plays nicely with the rest of the iOS embedder. This does include a couple minor cleanups in
#include/#importorder and usage to match our style guide.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.