Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Handle deprecation of Dart_TimelineEvent Embedder API #42497

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

derekxu16
Copy link
Contributor

@derekxu16 derekxu16 commented Jun 1, 2023

This PR changes usages of Dart_TimelineEvent to Dart_RecordTimelineEvent as Dart_TimelineEvent was deprecated in https://dart-review.googlesource.com/c/sdk/+/308721.

@flutter-dashboard flutter-dashboard bot added the embedder Related to the embedder API label Jun 1, 2023
@@ -116,8 +116,10 @@ class Pipeline {

ProducerContinuation(const Continuation& continuation, size_t trace_id)
: continuation_(continuation), trace_id_(trace_id) {
TRACE_EVENT_ASYNC_BEGIN0_WITH_FLOW_IDS("flutter", "PipelineItem",
trace_id_, /*flow_id_count=*/1,
/*flow_ids=*/&trace_id_);
TRACE_FLOW_BEGIN("flutter", "PipelineItem", trace_id_);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't do anything because flow events don't bind to async events in Chrome's trace format.

@derekxu16 derekxu16 marked this pull request as ready for review June 1, 2023 21:36
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

This needs a test, and it looks like CI isn't happy.

What's a case where we'd ever want more than 1 flow ID? It looks like it's always either 1 or 0. Can we just make the API take a single parameter and assume the count is always 1 if it's not nullptr?

@derekxu16
Copy link
Contributor Author

This needs a test, and it looks like CI isn't happy.

I haven't landed the Dart CL yet, because it will break Dart SDK into Flutter Engine rolls. I'd like to get this PR approved first, and then I'll be able to include these changes with the rolling of the embedder API changes. CI will only pass when these changes are included with the rolling of the embedder API changes. I'm not sure how to write a test for this, do you have an example I can follow?

What's a case where we'd ever want more than 1 flow ID? It looks like it's always either 1 or 0. Can we just make the API take a single parameter and assume the count is always 1 if it's not nullptr?

Animator has events that are linked to multiple flow events

while (!trace_flow_ids_.empty()) {

while (!self->trace_flow_ids_.empty()) {

@dnfield
Copy link
Contributor

dnfield commented Jun 5, 2023

I haven't landed the Dart CL yet, because it will break Dart SDK into Flutter Engine rolls

If we can in any way avoid the need for a manual roll we should. It makes things like reverts/relands much harder, and ends up making the release process more complicated. Can we avoid that here?

@dnfield
Copy link
Contributor

dnfield commented Jun 5, 2023

(Thanks for the pointer about multiple flow ids)

@derekxu16
Copy link
Contributor Author

If we can in any way avoid the need for a manual roll we should. It makes things like reverts/relands much harder, and ends up making the release process more complicated. Can we avoid that here?

I think a manual roll has to be done here, because on the Dart side we are adding new required parameters to the Dart_TimelineEvent function, which will make all existing calls to Dart_TimelineEvent have the wrong number of arguments. We can't get around it by adding them as optional parameters, because dart_tools_api.h is only supposed to use C features (https://dart-review.googlesource.com/c/sdk/+/302963/comment/a70bff54_1920bed7/).

We can make the number of Engine changes included in the manual roll smaller though. There aren't many direct calls to Dart_TimelineEvent, so we can just pass flow_id_count=0 and flow_ids=nullptr to those when doing the roll. Then we can update the TRACE_EVENT_* macros in a separate PR. Would that be any better?

@dnfield
Copy link
Contributor

dnfield commented Jun 5, 2023

Why can't we deprecate the old method and create a new one?

@derekxu16
Copy link
Contributor Author

I just discussed this with @bkonyi. We would prefer not to go through the extra deprecation / cleanup process since this function is only used in a couple of places in the Engine. Let us know if you still strongly desire to avoid the manual roll.

@zanderso
Copy link
Member

zanderso commented Jun 8, 2023

@derekxu16 @bkonyi It looks like there's a straightforward way to do a soft transition for this API, so that's what we should do. Manual rolls are for emergencies or cases where a soft transition is impossible.

@github-actions github-actions bot removed the embedder Related to the embedder API label Jun 14, 2023
@derekxu16 derekxu16 changed the title Handle breaking change to Dart_TimelineEvent Embedder API Handle deprecation of Dart_TimelineEvent Embedder API Jun 14, 2023
@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 to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

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.

@derekxu16
Copy link
Contributor Author

I'll be able to test this in https://github.com/flutter/engine/blob/main/testing/dart/observatory/tracing_test.dart once https://dart-review.googlesource.com/c/sdk/+/303022 lands. I need that CL to land because it will allow me to decode Perfetto-format trace protos and check that flow IDs are present in them. That CL is currently blocked for the reasons described here: https://dart-review.googlesource.com/c/sdk/+/303022/comment/d77751a4_f9e8fea8. I'll revist this PR once that CL lands.

@derekxu16 derekxu16 force-pushed the flow-events branch 4 times, most recently from 3505e9e to f1ee191 Compare June 20, 2023 15:19
@derekxu16
Copy link
Contributor Author

derekxu16 commented Jun 21, 2023

The Linux linux_unopt check is failing because it's detecting a leak. I think it's because flutter_tester is not cleaning up the VM properly. I added print statements to dart::Cleanup in third_party/dart/runtime/vm/dart.cc, built the engine with --no-prebuilt-dart-sdk, ran the --type=dart tests, and never saw the string that I printed.

We have a test in the VM that passes flow ID arguments to Dart_RecordTimelineEvent, and ASAN doesn't detect leaks when running that test. https://github.com/dart-lang/sdk/blob/b64fc318e715081c3ce99ae3242e598886cb3ce2/runtime/vm/dart_api_impl_test.cc#L10416

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

@dnfield
Copy link
Contributor

dnfield commented Jul 31, 2023

(From offline discussion - we leak the VM by default, the tester should not need to leak the VM, setting it to not leak the VM makes ASAN happy)

This PR changes usages of Dart_TimelineEvent to Dart_RecordTimelineEvent as Dart_TimelineEvent was deprecated in https://dart-review.googlesource.com/c/sdk/+/308721
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM as long as bots are happy - I rekicked one that seemed like an infra failure.

@derekxu16 derekxu16 merged commit e8710ac into flutter:main Aug 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2023
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Aug 3, 2023
…sions) (#131830)

Manual roll requested by [email protected]

flutter/engine@9304c00...4c1157b

2023-08-03 [email protected] Revert Android Hardware Texture PRs (flutter/engine#44310)
2023-08-03 [email protected] Roll Dart SDK from 87df1bbcea5e to 3b9af2825d47 (2 revisions) (flutter/engine#44308)
2023-08-03 [email protected] Roll Fuchsia Mac SDK from Hx7ap5qcoqRIknnnG... to WwFjJuQF_rpToCYPJ... (flutter/engine#44306)
2023-08-03 [email protected] Check whether the lookup of android.hardware.HardwareBuffer found a class (flutter/engine#44304)
2023-08-02 [email protected] [Impeller] Add placeholder filter input. (flutter/engine#44290)
2023-08-02 [email protected] Roll ANGLE from 6c1bab070220 to 6a09e41ce6ea (1 revision) (flutter/engine#44300)
2023-08-02 [email protected] Roll Skia from fd5bd67d532f to c0956a252f30 (1 revision) (flutter/engine#44296)
2023-08-02 [email protected] [iOS] Fix use-after-free in setBinaryMessenger (flutter/engine#44294)
2023-08-02 [email protected] Add Search Web to selection controls on iOS (flutter/engine#43324)
2023-08-02 [email protected] Improve logging in the clang-tidy script (flutter/engine#44228)
2023-08-02 [email protected] Roll ANGLE from 335c6b86d70b to 6c1bab070220 (1 revision) (flutter/engine#44291)
2023-08-02 [email protected] Roll Skia from 25f5a32367ad to fd5bd67d532f (2 revisions) (flutter/engine#44289)
2023-08-02 [email protected] Be sure to clear exceptions after a failed JNI lookup (flutter/engine#44293)
2023-08-02 [email protected] Handle deprecation of Dart_TimelineEvent Embedder API (flutter/engine#42497)
2023-08-02 [email protected] Roll Skia from ccc17f784e5d to 25f5a32367ad (4 revisions) (flutter/engine#44283)
2023-08-02 [email protected] Roll ANGLE from 01ee134bb223 to 335c6b86d70b (2 revisions) (flutter/engine#44287)
2023-08-02 [email protected] Roll Skia from 7104d0e8863f to ccc17f784e5d (2 revisions) (flutter/engine#44279)
2023-08-02 [email protected] [ios][autocorrection]disable auto-correction highlight in iOS 17 (flutter/engine#44176)
2023-08-02 [email protected] Reland Introduce TextureRegistry.ImageTexture and HardwareBufferExternalTextureGL (flutter/engine#44278)
2023-08-02 [email protected] Roll Dart SDK from afbaf4216fc8 to 87df1bbcea5e (1 revision) (flutter/engine#44276)
2023-08-02 [email protected] Roll Skia from 93764a98b866 to 7104d0e8863f (4 revisions) (flutter/engine#44273)
2023-08-02 [email protected] [Impeller] Fix leak of wrapped TextureMTL objects in the Metal embedder API (flutter/engine#44245)
2023-08-02 [email protected] Revert "Listen to window notifications to update application lifecycle" (flutter/engine#44275)
2023-08-02 [email protected] Roll Skia from 514c66ce0471 to 93764a98b866 (1 revision) (flutter/engine#44270)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from Hx7ap5qcoqRI to WwFjJuQF_rpT

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],[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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@derekxu16 derekxu16 deleted the flow-events branch August 3, 2023 15:20
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
This PR changes usages of `Dart_TimelineEvent` to
`Dart_RecordTimelineEvent` as `Dart_TimelineEvent` was deprecated in
https://dart-review.googlesource.com/c/sdk/+/308721.
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.

3 participants