Skip to content

Ignore ProfileChunk entries that have no useful data#4485

Merged
julienw merged 3 commits into
firefox-devtools:mainfrom
julienw:fix-chrome-importer
Feb 22, 2023
Merged

Ignore ProfileChunk entries that have no useful data#4485
julienw merged 3 commits into
firefox-devtools:mainfrom
julienw:fix-chrome-importer

Conversation

@julienw

@julienw julienw commented Feb 20, 2023

Copy link
Copy Markdown
Contributor

Fixes #4308

You'll probably surprised by some of the changes in the first commit: indeed when I changed the types for the Chrome importer, this produced a chain of Flow errors that I tried to fix with the simplest changes. Hopefully that will be OK.

Then I was surprised that these type changes didn't show the problem afterwards: Flow wouldn't error on this line.

I didn't investigate more as I wanted to fix the issue and didn't want to spend more time than necessary on this.

You can test with the profile from #4308 or alternatively the profile from bugzilla bug 1817623.

production / deploy preview

@julienw julienw requested a review from canova February 20, 2023 14:43
expect(profile).toMatchSnapshot();
});

it('successfully imports a chrome profile with an invalid "endTime" entry', async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I chcked that this test was crashing on the main branch.

const text = buffer.toString('utf8');
const buffer = zlib.gunzipSync(compressedBuffer);
const events: TracingEventUnion[] = JSON.parse(buffer.toString('utf8'));
events.push({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this data comes directly from one of the failing profiles.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the test!

@julienw julienw force-pushed the fix-chrome-importer branch from a81ab8a to 602fcf7 Compare February 20, 2023 14:45
});

it('successfully imports a non-chunked profile (one that uses a CpuProfile trace event)', async function () {
const fs = require('fs');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: I removed the Image.addEventListener mock for this test because this is used for the screenshots, and the unchunked profile doesn't have any.

data.category === 'Navigation' &&
data.innerWindowID
) {
const innerWindowID = data.innerWindowID;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Flow was failing with innerWindowID is missing in ChromeDurationTraceEventPayload` and this is the only way I could silence it.

Comment thread src/types/markers.js
export type ChromeDurationTraceEventPayload = {|
type: 'tracing',
category: 'FromChrome',
category: string,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For some reason this started to error after I added FallbackEndEvent 🤔 Indeed there's a place where we pass an arbitrary string...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh interesting. Good to put it as string then if we have a place where we pass an arbitrary string.

@codecov

codecov Bot commented Feb 20, 2023

Copy link
Copy Markdown

Codecov Report

Base: 88.64% // Head: 88.64% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (602fcf7) compared to base (7f60386).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 602fcf7 differs from pull request most recent head c3edf91. Consider uploading reports for the commit c3edf91 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4485   +/-   ##
=======================================
  Coverage   88.64%   88.64%           
=======================================
  Files         284      284           
  Lines       25591    25588    -3     
  Branches     6885     6883    -2     
=======================================
- Hits        22684    22682    -2     
+ Misses       2702     2701    -1     
  Partials      205      205           
Impacted Files Coverage Δ
src/components/timeline/VerticalIndicators.js 100.00% <100.00%> (ø)
src/profile-logic/import/chrome.js 94.60% <100.00%> (+0.03%) ⬆️
src/selectors/per-thread/composed.js 100.00% <0.00%> (+3.12%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@canova canova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, thanks for fixing this annoying issue!

const text = buffer.toString('utf8');
const buffer = zlib.gunzipSync(compressedBuffer);
const events: TracingEventUnion[] = JSON.parse(buffer.toString('utf8'));
events.push({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the test!

Comment thread src/types/markers.js
export type ChromeDurationTraceEventPayload = {|
type: 'tracing',
category: 'FromChrome',
category: string,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh interesting. Good to put it as string then if we have a place where we pass an arbitrary string.

@julienw

julienw commented Feb 22, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

@julienw julienw enabled auto-merge February 22, 2023 18:28
@julienw julienw merged commit dc2d10d into firefox-devtools:main Feb 22, 2023
@canova canova mentioned this pull request Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot import this Chrome profile: "TypeError: undefined has no properties"

2 participants