-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Fix App crash when use WebView with iOS VoiceOver #52484
Conversation
cc @jmagman |
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 fix is checked by the
testFlutterPlatformViewSemanticsContainer
function in theSemanticsObjectTest.mm
.
The result is not changed.
Are you able to get a test to fail/crash on main but succeed on this PR, that actually exercises the bad behavior? Your fix looks more correct, but in practice I can't see how it's actually changing the retains in a way that would prevent a crash.
This test, for example, passed on both main and this PR:
- (void)testFlutterPlatformViewSemanticsContainer {
fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
new flutter::testing::MockAccessibilityBridge());
fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
__weak FlutterTouchInterceptingView* weakPlatformView;
__weak FlutterPlatformViewSemanticsContainer* weakContainer;
@autoreleasepool {
FlutterTouchInterceptingView* platformView = [[FlutterTouchInterceptingView alloc] init];
weakPlatformView = platformView;
@autoreleasepool {
FlutterPlatformViewSemanticsContainer* container =
[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge
uid:1
platformView:platformView];
weakContainer = container;
XCTAssertEqualObjects(platformView.accessibilityContainer, container);
XCTAssertNotNil(weakPlatformView);
XCTAssertNotNil(weakContainer);
}
XCTAssertNotNil(weakPlatformView);
XCTAssertNil(weakContainer);
}
// Check if there's no more strong references to `platformView` after container and platformView
// are released.
XCTAssertNil(weakPlatformView);
XCTAssertNil(weakContainer);
}
By the way, I'm hoping to migrate FlutterPlatformViews
to ARC soon to prevent these kinds of issues 🙂
@jmagman
This test verifies that the
That's great. |
Hm, this test also passes on main though. |
I validated my fixes and tests using the following process. Download tools and add PATH.
Download the code and prepare.
git pull again at 2024/05/09 11:00+09:00 (2024/05/09 02:00+00:00 UTC)
Build engine.
Do test.
Result:
Now, I think the environment is set up. Patch the test code and do the below again.
Result:
This means that the test code catches the checkpoint in the main branch, I think. Patch all code and do above again. Result:
This means that the product code fix the probrem, I think. |
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.
Apologies for wasting your time, you're totally right, I was running the test incorrectly (I was playing around with bin/et
and it output to out/ci/ios_debug_unopt_sim_arm64
instead of out/ios_debug_sim_unopt
😓
FLUTTER_ENGINE[arch=x86_64]=ios_debug_sim_unopt | |
FLUTTER_ENGINE[arch=arm64]=ios_debug_sim_unopt_arm64 | |
FLUTTER_ENGINE=ios_debug_sim_unopt_arm64 |
)
LGTM, thanks for the fix!
|
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.
Good catch! Thanks for digging into this.
[platformView setFlutterAccessibilityContainer:self]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc { | ||
[_platformView release]; | ||
_platformView = nil; |
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.
nit: it's not necessary to nil out the ivar (can remove the whole dealloc method here).
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'm about to remove this dealloc in #52535, I wouldn't worry about it in this PR.
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.
Oh actually that's not true, the PR doesn't include SemanticsObject
. But I'll get to that one hopefully soon 🙂
…148137) flutter/engine@c0917b1...1ccd0c3 2024-05-10 [email protected] Fixed constness of display list storage. (flutter/engine#52705) 2024-05-10 [email protected] Revert "Various documentation improvements (#52600)" (flutter/engine#52709) 2024-05-10 [email protected] Manual roll Dart SDK from b7cad2edae4b to 01121c008f4d (3 revisions) (flutter/engine#52706) 2024-05-10 [email protected] [iOS] Fix App crash when use WebView with iOS VoiceOver (flutter/engine#52484) 2024-05-09 [email protected] Various documentation improvements (#52600) (flutter/engine#52623) 2024-05-09 [email protected] [web] scale semantic text elements to match the desired focus ring size (flutter/engine#52586) 2024-05-09 [email protected] [Impeller] Adds impeller display list golden tests (flutter/engine#52690) 2024-05-09 [email protected] Roll buildroot to 70a42312a688 (flutter/engine#52675) 2024-05-09 [email protected] When `et` is not attached to a terminal, still split lines for status updates. (flutter/engine#52681) 2024-05-09 [email protected] updated analysis exclusion (flutter/engine#52699) 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
@zanderso any idea if this fix will be released as a patch of the current release 3.22 ! |
This fix is in 3.23.0-10.0.pre which hasn't reached the beta channel yet. See https://github.com/flutter/flutter/blob/master/docs/releases/Hotfixes-to-the-Stable-Channel.md |
Any progress? |
@JDongKhan |
This PR fix the issue flutter/flutter #140528.
This fix cleans up declarations regarding
retain
andrelease
.flutterAccessibilityContainer
needs to be managed inFlutterPlatformViews.mm
, and problems will occur ifretain
orrelease
is performed inSemanticsObject.mm
.This fix is checked by the
testFlutterPlatformViewSemanticsContainer
function in theSemanticsObjectTest.mm
.The result is not changed.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.