-
Notifications
You must be signed in to change notification settings - Fork 6k
[ios_platform_view, a11y] Make FlutterPlatformViewSemanticsContainer a SemanticsObject.
#29531
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. 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. |
|
Some old tests might be failing due to this change, I'll work on the tests later |
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | ||
| uid:(int32_t)uid | ||
| __attribute__((unavailable("Use initWithBridge:uid:platformViewId instead"))); |
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.
We should instead use NS_UNAVAILABLE and NS_DESIGNATED_INITIALIZER for this pattern.
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | |
| uid:(int32_t)uid | |
| __attribute__((unavailable("Use initWithBridge:uid:platformViewId instead"))); | |
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | |
| uid:(int32_t)uid NS_UNAVAILABLE; |
| if ([element isKindOfClass:[FlutterPlatformViewSemanticsContainer class]]) { | ||
| return ((FlutterPlatformViewSemanticsContainer*)element).index; | ||
| } |
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.
Nice, I found this pretty confusing when I was stepping through, part of the bug seemed to be that the index was set by one container, then accessed by another?
Can you update the description to explain exactly what the bug was, for posterity?
Co-authored-by: Jenn Magder <[email protected]>
|
Verified the bug no longer reproduces on this PR. |
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | ||
| uid:(int32_t)uid { | ||
| return [super init]; |
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.
FAILED: obj/flutter/shell/platform/darwin/ios/framework/Source/flutter_framework_source.SemanticsObject.o
/opt/s/w/ir/cache/goma/client/gomacc ../../buildtools/mac-x64/clang/bin/clang++ -MD -MF obj/flutter/shell/platform/darwin/ios/framework/Source/flutter_framework_source.SemanticsObject.o.d -DFLUTTER_FRAMEWORK=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DSHELL_ENABLE_SOFTWARE -DSHELL_ENABLE_GL -DSHELL_ENABLE_METAL -DSK_GL -DSK_METAL -DSK_CODEC_DECODES_JPEG -DSK_ENCODE_JPEG -DSK_CODEC_DECODES_PNG -DSK_ENCODE_PNG -DSK_CODEC_DECODES_WEBP -DSK_ENCODE_WEBP -DSK_HAS_WUFFS_LIBRARY -DSK_ENABLE_DUMP_GPU -DSK_DISABLE_AAA -DSK_PARAGRAPH_LIBTXT_SPACES_RESOLUTION -DSK_LEGACY_INNER_JOINS -DSK_DISABLE_LEGACY_SHADERCONTEXT -DSK_DISABLE_LOWP_RASTER_PIPELINE -DSK_FORCE_RASTER_PIPELINE_BLITTER -DSK_DISABLE_EFFECT_DESERIALIZATION -DSK_ENABLE_SKSL -DSK_ASSUME_GL_ES=1 -DSK_ENABLE_API_AVAILABLE -DFLUTTER_RUNTIME_MODE_DEBUG=1 -DFLUTTER_RUNTIME_MODE_PROFILE=2 -DFLUTTER_RUNTIME_MODE_RELEASE=3 -DFLUTTER_RUNTIME_MODE_JIT_RELEASE=4 -DDART_LEGACY_API=\[\[deprecated\]\] -DFLUTTER_RUNTIME_MODE=1 -DFLUTTER_JIT_RUNTIME=1 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DRAPIDJSON_HAS_STDSTRING -DRAPIDJSON_HAS_CXX11_RANGE_FOR -DRAPIDJSON_HAS_CXX11_RVALUE_REFS -DRAPIDJSON_HAS_CXX11_TYPETRAITS -DRAPIDJSON_HAS_CXX11_NOEXCEPT -DFLUTTER_API_SYMBOL_PREFIX=Embedder -DFLUTTER_NO_EXPORT -I../.. -Igen -I../../third_party/skia -I../../third_party/vulkan/src -I../../third_party/vulkan/include -I../../flutter/third_party/txt/src -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/rapidjson -I../../third_party/rapidjson/include -I../../third_party/dart/runtime -I../../third_party/dart/runtime/include -I../../flutter/third_party -I../../flutter -I../../flutter/shell/platform/darwin/common/framework/Headers -isysroot /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.0.sdk -mios-simulator-version-min=9.0 -fno-strict-aliasing -arch x86_64 -fcolor-diagnostics -Wall -Wextra -Wendif-labels -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-deprecated-copy -Wno-psabi -Wno-non-c-typedef-for-linkage -Wno-range-loop-construct -Wunguarded-availability -Wno-deprecated-declarations -fvisibility=hidden -stdlib=libc++ -Wstring-conversion -Wnewline-eof -Os -fno-ident -fdata-sections -ffunction-sections -g2 -Werror=overriding-method-mismatch -Werror=undeclared-selector -fvisibility-inlines-hidden -fobjc-call-cxx-cdtors -std=c++17 -fno-rtti -fno-exceptions -nostdinc++ -isystem /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 -c ../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm -o obj/flutter/shell/platform/darwin/ios/framework/Source/flutter_framework_source.SemanticsObject.o
../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm:760:17: error: convenience initializer should not invoke an initializer on 'super' [-Werror,-Wobjc-designated-initializers]
return [super init];
Other places in this file do this
// Method declared as unavailable in the interface
- (instancetype)init {
[self release];
[super doesNotRecognizeSelector:_cmd];
return nil;
}
But it's not necessary since you've marked the method as unavailable. If you try to call it, you'll get a compilation error:
error: 'initWithBridge:uid:' is unavailable
So you can remove this -[initWithBridge:uid:] implementation
|
I tried to run the tests locally and got: It is probably related to something in my local engine build since CI builds fine. |
|
Include |
Line 297 in 541779d
ios_test_flutter artifacts are built too, not just ios_debug_sim_unopt. @cyanglaz can you file an issue?
|
|
@jmagman Ready to review :) |
jmagman
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.
LGTM! Might be worth some extensive manual testing if you haven't already to see if there's any fallout to this.
|
|
||
| SemanticsObject* child = [_semanticsObject children][index - 1]; | ||
|
|
||
| // Swap the original `SemanticsObject` to a `PlatformViewSemanticsContainer` |
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.
Why was this pattern used in the first place? #8156
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 don't really remember a particular reason the old pattern was used. I don't think the new pattern was ever considered when I first implemented this.
|
@cyanglaz can any of this be applied to the FlutterSemanticsScrollView implementation? It seems like there may be som eoverlap but I feel like I'm missing a piece. |
…ontainer` a SemanticsObject. (flutter/engine#29531)
…` a SemanticsObject. (#29531) (#29725) Co-authored-by: Chris Yang <[email protected]>
| - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction { | ||
| return [_platformView accessibilityScroll:direction]; | ||
| - (NSArray*)accessibilityElements { | ||
| return @[ _platformView ]; |
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.
you can override the nativeAccessibility prop gettter to return the _platformView
This PR makes
FlutterPlatformViewSemanticsContaineraSemanticsObject.This change removed the reference to a
SemanticsObjectin theFlutterPlatformViewSemanticsContainer.Now a
FlutterPlatformViewSemanticsContaineronly contains a single a11yElement, which is the platform view.This resolve the retain cycle just like how #24308 tried to resolve.
This also avoid the protocol pattern introduced in #24308, which seems making platform view drop parent reference.
fixes flutter/flutter#93024
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.