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

Adds a destruction_callback member to FlutterTaskRunnerDescription that provides embedder developers a means of performing any cleanup of resources tied to the lifetime of the task runner.

In the case of the macOS embedder, the task runner holds a reference to the engine itself that is used in the post_task_callback and whose lifetime needs to match/exceed that of the task runner. This refactoring allows us to centralise all related retain count manipulation around task runner setup.

This is a refactor of the lifecycle bits of #13300.

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.

@cbracken
Copy link
Member Author

cbracken commented Nov 8, 2024

This is a "what do you think about this approach?" patch. There are other ways we could do this but it has the nice property that we have similar destruction_callbacks on other objects that we effectively hand ownership of a resource to (the surface classes in the embedder API), and it's nice that it colocates all the lifecycle crap on the object that needs it.

Task runner destruction happens during the result = _embedderAPI.Shutdown(_engine); call in FlutterEngine.mm on the very next line from where we do the CFRelease today.

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 with the comment suggestion (and a preference for the bridge-based retain count management, but LGTM either way).

Adds a `destruction_callback` member to `FlutterTaskRunnerDescription` that provides embedder developers a means of performing any cleanup of resources tied to the lifetime of the task runner.

In the case of the macOS embedder, the task runner holds a reference to the engine itself that is used in the `post_task_callback` and whose lifetime needs to exceed that of the task runner. This refactoring allows us to centralise all related retain count manipulation around task runner setup.

This is a refactor of the lifecycle bits of #13300.
@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 8, 2024
@cbracken
Copy link
Member Author

cbracken commented Nov 8, 2024

Talked to @chinmaygarde as well and got a verbal lgtm.

@auto-submit auto-submit bot merged commit 6b77347 into flutter:main Nov 8, 2024
30 checks passed
@cbracken cbracken deleted the no-cfrelease-macos-engine branch November 8, 2024 20:50
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 8, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Nov 8, 2024
…158398)

flutter/engine@1b567e8...6b77347

2024-11-08 [email protected] Add FlutterTaskRunnerDescription.destruction_callback (flutter/engine#56445)
2024-11-08 [email protected] Roll Skia from d0ee80612f86 to 778b21720a61 (5 revisions) (flutter/engine#56457)
2024-11-08 [email protected] Manual roll Dart SDK from 50c620224f27 to cfa1826c3df1 (2 revisions) (flutter/engine#56456)
2024-11-08 [email protected] [Impeller] Switch to uniform arrays for gradient data on non-SSBO hardware (flutter/engine#56441)

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
…#56445)

Adds a `destruction_callback` member to `FlutterTaskRunnerDescription` that provides embedder developers a means of performing any cleanup of resources tied to the lifetime of the task runner.

In the case of the macOS embedder, the task runner holds a reference to the engine itself that is used in the `post_task_callback` and whose lifetime needs to match/exceed that of the task runner. This refactoring allows us to centralise all related retain count manipulation around task runner setup.

This is a refactor of the lifecycle bits of flutter/engine#13300.

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

Labels

affects: desktop autosubmit Merge PR when tree becomes green via auto submit App platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants