-
Notifications
You must be signed in to change notification settings - Fork 6k
iOS: Refactor ShellTestPlatformViewMetal #56370
iOS: Refactor ShellTestPlatformViewMetal #56370
Conversation
|
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. |
Migrates DarwinContextMetal to a plain C struct, eliminating the need for constructor, getters, etc. since it's only used in this translation unit. The fields themselves cannot be inlined as fields on ShellTestPlatformViewMetal because the header in which that class is defined is included in plain C++ (non-Obj-C++) translation units and therefore cannot contain Obj-C types. This simplifies the code and simultaneously fixes complicated ARC behaviour in which the const "DarwinContextMetal::context()" getter caused refcount to be incremented on the underlying context_ pointer, but not decremented even if never unassigned. In particular the line ```objc FML_CHECK([metal_context->context() mainContext])); ``` appeared to cause refcount to be incremented but never decremented. Regardless of the ARC issue, this significantly simplifies the code. This also eliminates the last remaining use of fml::scoped_nsobject in Flutter's codebase. That class will be removed in a followup PR. Issue: flutter/flutter#137801
| vsync_clock_(std::move(vsync_clock)), | ||
| shell_test_external_view_embedder_(std::move(shell_test_external_view_embedder)) { | ||
| if (GetSettings().enable_impeller) { | ||
| FML_CHECK([metal_context_->impeller_context() context] != 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.
[impeller_context context] and [skia_context context] here and below was an sk_sp, not a plain Obj-C pointer. I don't see any implicit type conversion operators defined in there but that type does implement operator bool() so using that instead for the sanity of readers.
| impeller ? [[FlutterDarwinContextMetalImpeller alloc] init:is_gpu_disabled_sync_switch] | ||
| : nil), | ||
| offscreen_texture_(CreateOffscreenTexture( | ||
| impeller ? [impeller_context_ context]->GetMTLDevice() : [context_ device])) {} |
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 is now done in the static CreateDarwinContext func above, which inlines CreateOffscreenTexture since it was only used here.
None of the rest of the getter boilerplate is necessary.
| // non-Objective-C TUs. | ||
| struct DarwinContextMetal { | ||
| FlutterDarwinContextMetalSkia* skia_context; | ||
| FlutterDarwinContextMetalImpeller* impeller_context; |
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.
Could this have been a union or std::variant? Yes. But we're going to delete the skia backend eventually anyway, so may as well avoid the extra complexity and make life easy on the person who deletes it.
jonahwilliams
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.
RSLGTM
stuartmorgan-g
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
I agree this should be a std::variant instead, but also that adding the complexity at this point isn't warranted.
|
test-exempt: code refactor with no semantic change |
…158218) flutter/engine@e5e06c9...a3741d6 2024-11-05 [email protected] Increase timeouts for Linux Fuchsia and Linux Web Framework Tests builders (flutter/engine#56387) 2024-11-05 [email protected] iOS: Use standard Obj-C cflags for ios_test_flutter (flutter/engine#56384) 2024-11-05 [email protected] Remove unnecessary method for getting engine switches (command line). (flutter/engine#56265) 2024-11-05 [email protected] Remove FlScrollingViewDelegate (flutter/engine#56270) 2024-11-05 [email protected] fml: delete scoped_nsobject.h,mm (flutter/engine#56382) 2024-11-05 [email protected] Roll Skia from b3be9cb59fe8 to 82175b411c80 (2 revisions) (flutter/engine#56383) 2024-11-05 [email protected] [Impeller] Delete any remaining GL objects during destruction of the ReactorGLES (flutter/engine#56361) 2024-11-05 [email protected] [web] Switch all fonts to WOFF2 (non-split) (flutter/engine#56035) 2024-11-05 [email protected] [Impeller] exploit content context options' perfect hash function. (flutter/engine#56360) 2024-11-05 [email protected] Roll Skia from 7989f782dbf4 to b3be9cb59fe8 (6 revisions) (flutter/engine#56380) 2024-11-05 [email protected] Roll Dart SDK from b39c729740eb to 3e840340c412 (1 revision) (flutter/engine#56377) 2024-11-05 [email protected] [Impeller] match Skia's old VMA default block size. (flutter/engine#56368) 2024-11-05 [email protected] iOS: Refactor ShellTestPlatformViewMetal (flutter/engine#56370) 2024-11-05 [email protected] Roll Fuchsia Linux SDK from amgHXcqtplha8LuI_... to z1otZzn3yKuGnu1st... (flutter/engine#56374) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from amgHXcqtplha to z1otZzn3yKuG 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
Migrates DarwinContextMetal to a plain C struct, eliminating the need for constructor, getters, etc. since it's only used in this translation unit. The fields themselves cannot be inlined as fields on ShellTestPlatformViewMetal because the header in which that class is defined is included in plain C++ (non-Obj-C++) translation units and therefore cannot contain Obj-C types. This simplifies the code and simultaneously fixes complicated ARC behaviour in which the const "DarwinContextMetal::context()" getter caused retainCount to be incremented on the underlying context_ pointer, but not decremented even if never unassigned. In particular the line ```objc FML_CHECK([metal_context->context() mainContext])); ``` appeared to cause refcount to be incremented but never decremented. Regardless of the ARC issue, this significantly simplifies the code. This also eliminates the last remaining use of fml::scoped_nsobject in Flutter's codebase. That class will be removed in a followup PR. No test changes since there is no change to semantics. Issue: flutter#137801 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Migrates DarwinContextMetal to a plain C struct, eliminating the need for constructor, getters, etc. since it's only used in this translation unit. The fields themselves cannot be inlined as fields on ShellTestPlatformViewMetal because the header in which that class is defined is included in plain C++ (non-Obj-C++) translation units and therefore cannot contain Obj-C types.
This simplifies the code and simultaneously fixes complicated ARC behaviour in which the const "DarwinContextMetal::context()" getter caused retainCount to be incremented on the underlying context_ pointer, but not decremented even if never unassigned. In particular the line
appeared to cause refcount to be incremented but never decremented.
Regardless of the ARC issue, this significantly simplifies the code.
This also eliminates the last remaining use of fml::scoped_nsobject in Flutter's codebase. That class will be removed in a followup PR.
No test changes since there is no change to semantics.
Issue: flutter/flutter#137801
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.