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

Conversation

@cbracken
Copy link
Member

@cbracken cbracken commented Nov 26, 2024

This is a minor refactoring that moves a global bool to a boolean ivar in FlutterPlatformViewsController. The purpose of this variable is simply to avoid the overhead of trying to create backdrop filters if we've ever failed to create one in the past.

Given that this class will only ever have the one instance created and held by per engine with the same duration, and that most apps only ever have one engine, the performance win will be identical for most apps. For the few add-to-app cases with multiple engines either at once or over the course of an app's lifetime, the costs associated with firing up an engine are already a far bigger hit than those being saved by this bool.

Also migrates from C++ style namespace { ... } to Obj-C style static functions. These are entirely equivalent as both restrict symbols to the current translation unit.

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.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

embeddedView:(UIView*)embeddedView
boundingRect:(const SkRect&)boundingRect {
// Becomes NO if Apple's API changes and blurred backdrop filters cannot be applied.
static BOOL sCanApplyBlurBackdrop = YES;
Copy link
Contributor

Choose a reason for hiding this comment

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

is the s prefix a common practice

Copy link
Member Author

Choose a reason for hiding this comment

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

Will double-check but my recollection was that the style guide recommends a k prefix for constants, a g prefix for mutable globals, and an s prefix for statics. I believe we enforce naming on constants and mutable globals in our .clang-tidy rules. Will double check when I’m back at a computer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this too, but it looks like it's not in the style guide.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose the right thing to do here is to just make this an ivar. The whole point appears to be just to avoid the overhead of trying to create backdrop filters if we've ever failed to create one in the past.

This class will only ever have the one instance created and held by the engine for the duration of its life. Most apps only ever have one engine and the add-to-app cases with multiple engines either at once or over the course of an app's lifetime are already taking a far bigger hit than those being saved by this bool.

Mostly, this approach saves me scratching my head trying to remember whether the s prefix rule was real or imagined.

@stuartmorgan-g
Copy link
Contributor

test-exempt: code refactor with no semantic change

This is a minor refactoring that moves a global bool to a static bool in
PlatformViewsController. This doesn't improve the logic but does limit
the scope of the bool to a single method.

Also migrates from C++ style namespace { ... } to Obj-C style static
functions. These are entirely equivalent, both restrict these symbols to
the current translation unit.
@cbracken cbracken changed the title iOS: Move global to static in platformviews controller iOS: Eliminate global in platformviews controller Nov 26, 2024
@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2024
@auto-submit auto-submit bot merged commit 752e2d7 into flutter:main Nov 26, 2024
30 checks passed
@cbracken cbracken deleted the eliminate-global branch November 26, 2024 18:51
auto-submit bot pushed a commit that referenced this pull request Nov 26, 2024
…#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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 26, 2024
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Nov 26, 2024
…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
auto-submit bot pushed a commit that referenced this pull request Nov 27, 2024
This is a minor refactoring that moves a global bool to a boolean ivar in FlutterPlatformViewsController. The purpose of this variable is simply to avoid the overhead of trying to create backdrop filters if we've ever failed to create one in the past.

Given that this class will only ever have the one instance created and held by per engine with the same duration, and that most apps only ever have one engine, the performance win will be identical for most apps. For the few add-to-app cases with multiple engines either at once or over the course of an app's lifetime, the costs associated with firing up an engine are already a far bigger hit than those being saved by this bool.

Also migrates from C++ style namespace { ... } to Obj-C style static functions. These are entirely equivalent as both restrict symbols to the current translation unit.

This is a reland of #56805, which was reverted as part of #56817.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
This is a minor refactoring that moves a global bool to a boolean ivar in FlutterPlatformViewsController. The purpose of this variable is simply to avoid the overhead of trying to create backdrop filters if we've ever failed to create one in the past.

Given that this class will only ever have the one instance created and held by per engine with the same duration, and that most apps only ever have one engine, the performance win will be identical for most apps. For the few add-to-app cases with multiple engines either at once or over the course of an app's lifetime, the costs associated with firing up an engine are already a far bigger hit than those being saved by this bool.

Also migrates from C++ style namespace { ... } to Obj-C style static functions. These are entirely equivalent as both restrict symbols to the current translation unit.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…gine#56831)

This is a minor refactoring that moves a global bool to a boolean ivar in FlutterPlatformViewsController. The purpose of this variable is simply to avoid the overhead of trying to create backdrop filters if we've ever failed to create one in the past.

Given that this class will only ever have the one instance created and held by per engine with the same duration, and that most apps only ever have one engine, the performance win will be identical for most apps. For the few add-to-app cases with multiple engines either at once or over the course of an app's lifetime, the costs associated with firing up an engine are already a far bigger hit than those being saved by this bool.

Also migrates from C++ style namespace { ... } to Obj-C style static functions. These are entirely equivalent as both restrict symbols to the current translation unit.

This is a reland of flutter/engine#56805, which was reverted as part of flutter/engine#56817.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants