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 12, 2024

In [FlutterSurface asFlutterMetalTexture] we return a FlutterMetalTexture whose user_data field holds a void* reference to the associated FlutterSurface.

For conistency with other parts of the codebase, this now uses ARC bridge casts to perform the additional retain and release of the associated surface rather than CoreFoundation functions CFBridgingRetain and CFBridigingRelease. In FlutterEngine, for example:

// Retain for use in post_task_callback. Released in destruction_callback.
.user_data = (__bridge_retained void*)self,
.runs_task_on_current_thread_callback = [](void* user_data) -> bool {
return [[NSThread currentThread] isMainThread];
},
.post_task_callback = [](FlutterTask task, uint64_t target_time_nanos,
void* user_data) -> void {
FlutterEngine* engine = (__bridge FlutterEngine*)user_data;
[engine postMainThreadTask:task targetTimeInNanoseconds:target_time_nanos];
},
.identifier = ++sTaskRunnerIdentifiers,
.destruction_callback =
[](void* user_data) {
// Balancing release for the retain when setting user_data above.
FlutterEngine* engine = (__bridge_transfer FlutterEngine*)user_data;
engine = nil;
},

Also migrates the code to initialise and immediately return the struct using field designators, and reorders the assignments to be in the declaration order specified in embedder.h as required by the C++ spec.

No changes to tests since this introduces no semantic change.

Issue: flutter/flutter#137801

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.

In `[FlutterSurface asFlutterMetalTexture]` we return a
`FlutterMetalTexture` whose `user_data` field holds a void* reference to
the associated `FlutterSurface`.

For conistency with other parts of the codebase, this now uses ARC
bridge casts to perform the additional retain and release of the
associated surface rather than CoreFoundataion functions
`CFBridgingRetain` and `CFBridigingRelease`.

Also migrates the code to initialise and immediately return the struct
using field designators, and reorders the assignments to be in the
declaration order specified in embedder.h as required by the C++ spec.

No changes to tests since this introduces no semantic change.

Issue: flutter/flutter#137801
@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.

@stuartmorgan-g
Copy link
Contributor

test-exempt: code refactor with no semantic change

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM

@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2024
@auto-submit auto-submit bot merged commit a57a4a7 into flutter:main Nov 12, 2024
30 checks passed
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2024
@cbracken cbracken deleted the arc-cast-fluttersurface branch November 12, 2024 21:56
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Nov 13, 2024
…158541)

flutter/engine@877abb9...08348c9

2024-11-12 [email protected] [Linux] Configure depth and stencil framebuffer attachments needed for Impeller (flutter/engine#56516)
2024-11-12 [email protected] macOS: ARC bridge casts for FlutterMetalTexture.user_data (flutter/engine#56518)
2024-11-12 [email protected] [Impeller] prevent no-op backend from throwing exceptions during image  decoding (flutter/engine#56522)
2024-11-12 [email protected] Roll Dart SDK from 69170fac244c to 5f42ef8f15d5 (4 revisions) (flutter/engine#56539)
2024-11-12 [email protected] Roll Fuchsia Linux SDK from BajfrJuYeyWvnBhuM... to z-cm2nR0aJ4lXfwZ0... (flutter/engine#56538)
2024-11-12 [email protected] Roll Skia from aa099ff91e2f to 7d5c206fc873 (6 revisions) (flutter/engine#56541)
2024-11-12 [email protected] [Impeller] In canvas_unittests, only create an MSAA offscreen texture if the platform supports MSAA (flutter/engine#56542)
2024-11-12 [email protected] [iOS] Fix slider semantics node answer to accessibility activate (flutter/engine#56427)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from BajfrJuYeyWv to z-cm2nR0aJ4l

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
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…gine#56518)

In `[FlutterSurface asFlutterMetalTexture]` we return a `FlutterMetalTexture` whose `user_data` field holds a `void*` reference to the associated `FlutterSurface`.

For conistency with other parts of the codebase, this now uses ARC bridge casts to perform the additional retain and release of the associated surface rather than CoreFoundation functions `CFBridgingRetain` and `CFBridigingRelease`. In FlutterEngine, for example:
https://github.com/flutter/engine/blob/67eb4ae000de830545670ef5de4cd08930a8ef2a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L648-L664

Also migrates the code to initialise and immediately return the struct using field designators, and reorders the assignments to be in the declaration order specified in embedder.h as required by the C++ spec.

No changes to tests since this introduces no semantic change.

Issue: flutter#137801

[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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants