Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Feb 12, 2020

Description

Add tracing to image cache calls outside of release mode. Looks like this:

image

And can be easily lined up with engine work to see what's going on. The small line dropping off of listener is to a cleanup routine that runs at the end of listening, which is too small to be visible at the zoom level of the screenshot (but is there!) :).

/cc @liyuqian @chinmaygarde @alml @ignatz @goderbauer @gaaclarke

Tests

I added the following tests:

I'm trying to figure out the right way to test this. I think we'll need to update a driver test and check that this data is in there to start, but I'm open to suggestions.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Feb 12, 2020
@fluttergithubbot
Copy link
Contributor

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.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@dnfield
Copy link
Contributor Author

dnfield commented Feb 12, 2020

I'm working on tests for this, need to land a couple other things to enable it first - #50663 and #50666

@dnfield
Copy link
Contributor Author

dnfield commented Feb 12, 2020

I tried to keep the package updates out of this but two more snuck in. Oh well.

@jonahwilliams
Copy link
Contributor

🤷‍♂️

You could try pinning it in update_packages.dart

Copy link
Contributor

@bkonyi bkonyi left a comment

Choose a reason for hiding this comment

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

Timeline code and test LGTM

List<TimelineEvent> events, List<Map<String, dynamic>> expected) {
for (final TimelineEvent event in events) {
for (int index = 0; index < expected.length; index += 1) {
if (expected[index]['name'] == event.json['name']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be cleaner if you did:

for (final e in expected) {
  ...
  if (_mapsEqual(expectedArgs, args)) {
    expected.remove(e);
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_mapsEqual assumes it's doing a flat map though, and there are no nested maps. I guess I could update it to check for that...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to short circuit the more expensive recursion this way though by keying on the name. It's faster to check that one property than to recurse the entire structure, which could become large as we add to these tests.

return;
TimelineTask timelineTask;
if (!kReleaseMode) {
timelineTask = TimelineTask()..start('ImageCache.setMaximumSize', arguments: <String, dynamic>{'value': value});
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You might want to consider breaking this into multiple lines (below as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@dnfield
Copy link
Contributor Author

dnfield commented Feb 12, 2020

This test either has to be rewritten (the dwds pinned version of vm_service is broken for what the test uses), or we have to get dwds to bump vmservice for this.

I'm separately going to open an internal CL to open up visibility for flutter to use this package.

@dnfield
Copy link
Contributor Author

dnfield commented Feb 13, 2020

I rewrote the test to not depend on package:vm_service. Filed dart-lang/webdev#899 to track getting that bumped in dwds and added a TODO.

@fluttergithubbot fluttergithubbot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Feb 13, 2020
@dnfield dnfield requested a review from bkonyi February 13, 2020 01:06
@dnfield dnfield mentioned this pull request Feb 13, 2020
13 tasks
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,7 @@
# Tracing tests

The tests in this folder must be run with `flutter test --enable-vmservice`,
Copy link
Member

Choose a reason for hiding this comment

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

Any chance you can check for this condition from within the test and just print this message if the test was run incorrectly?

Copy link
Member

Choose a reason for hiding this comment

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

(Readmes usually get ignored..)

Copy link
Member

Choose a reason for hiding this comment

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

Never mind, I see below that you already do this: 🌟

import 'dart:isolate' as isolate;

import 'package:flutter/painting.dart';

Copy link
Member

Choose a reason for hiding this comment

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

nit: I believe this blank line shouldn't be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -0,0 +1,7 @@
# Tracing tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole file or this line?

I think most of the folders in dev/ have a README.md - the goal of this one is to make it clear what kind of tests belong in here, and what's special about running them.

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't in dev though, this is in flutter/test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Thanks, good catch. Removed.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@dnfield dnfield merged commit 766bd70 into flutter:master Feb 13, 2020
@dnfield dnfield deleted the image_tracing branch February 13, 2020 22:04
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants