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

Fix UIVisualEffectView leak in platform view filter #52591

Merged
merged 1 commit into from
May 8, 2024

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented May 7, 2024

I found this while migrating FlutterPlatformViews_Internal.mm to ARC #52535. I'll land this first.

  if (_backdropFilterView != visualEffectView) {
    _backdropFilterView = [visualEffectView retain];
  }

should instead be something like:

  if (_backdropFilterView != visualEffectView) {
    id oldBackdropFilterView = _backdropFilterView;
    _backdropFilterView = [visualEffectView retain];
    [oldBackdropFilterView release];
  }

But that's already what the built-in MRC nonatomic, retain property setter does, so use that instead.

Added a test that passes on this PR and fails on main.

@jmagman jmagman self-assigned this May 7, 2024
if (_backdropFilterView != visualEffectView) {
_backdropFilterView = [visualEffectView retain];
}
self.backdropFilterView = visualEffectView;
Copy link
Member Author

Choose a reason for hiding this comment

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

The old _backdropFilterView value wasn't released when being set to a new visualEffectView. Instead of adding a release, instead use the existing retain property setter.

@@ -487,7 +487,6 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_OBJC_ARC = NO;
Copy link
Member Author

Choose a reason for hiding this comment

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

The test dylib is built with ARC from the BUILD.gn, so this doesn't do anything. But I found setting it explicitly to NO confusing, and it's unnecessary.

Comment on lines +284 to +285
XCTAssertNil(weakVisualEffectView1);
XCTAssertNil(weakVisualEffectView2);
Copy link
Member Author

Choose a reason for hiding this comment

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

This fails on main, passes on this PR.

@jmagman jmagman marked this pull request as ready for review May 8, 2024 20:07
@@ -595,6 +620,7 @@ - (void)testAddBackdropFilters {
XCTAssertEqual(originalView, newView);
id mockOrignalView = OCMPartialMock(originalView);
OCMReject([mockOrignalView removeFromSuperview]);
[mockOrignalView stopMocking];
Copy link
Member Author

Choose a reason for hiding this comment

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

Not related but this test was causing issues because the original view would eventually be dealloced after the test, which would call removeFromSuperview and the reject would fail. I'm not convinced this is testing anything since the reject isn't set up before the code is exercised, but that's investigation for another day...

}
XCTAssertTrue(
CGColorEqualToColor(visualEffectSubviewBackgroundColor, UIColor.clearColor.CGColor));
XCTAssertNil(weakVisualEffectView);
Copy link
Member Author

Choose a reason for hiding this comment

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

This passes on main, so wasn't actually a problem, but hey I wrote the test before I knew that so may as well keep it. These kinds of "weak" tests have been helpful as I've done ARC migration.

@jmagman jmagman requested a review from hellohuanlin May 8, 2024 20:10
@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2024
@auto-submit auto-submit bot merged commit dc6e438 into flutter:main May 8, 2024
28 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 9, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 9, 2024
…148030)

flutter/engine@bd58d2b...69f2d96

2024-05-08 [email protected] Roll Skia from 4e83fac12783 to 91088addfbd9 (1 revision) (flutter/engine#52691)
2024-05-08 [email protected] Roll Skia from df446841e3cd to 4e83fac12783 (2 revisions) (flutter/engine#52688)
2024-05-08 [email protected] Fix UIVisualEffectView leak in platform view filter (flutter/engine#52591)
2024-05-08 [email protected] [Impeller] initialize ahb swapchain with max entries. (flutter/engine#52670)
2024-05-08 [email protected] Roll Skia from 76f88de905be to df446841e3cd (3 revisions) (flutter/engine#52686)
2024-05-08 [email protected] Reland "Add host_profile_arm64 and host_release_arm64 local engine configurations." (flutter/engine#52633)
2024-05-08 [email protected] Roll Fuchsia Linux SDK from 27ZAbzJkEopmu0Emp... to RDVdjRvCxkJh2NLxS... (flutter/engine#52685)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from 27ZAbzJkEopm to RDVdjRvCxkJh

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
@jmagman jmagman deleted the backdropFilterView-release branch May 10, 2024 19:12
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.

2 participants