profiler icon indicating copy to clipboard operation
profiler copied to clipboard

Support Chrome's about:traces export format

Open digitarald opened this issue 4 years ago • 22 comments

STR: Load https://nparashuram.github.io/ChainReactApp2019/hermes/trace-hermes.json AR:

Error: "Unserializing the profile failed: TypeError: e.meta is undefined"
    $i process-profile.js:1149
    hl receive-profile.js:892

Tagging as feature, assuming there are a few differences between about:tracing and Chrome's Performance DevTools format.

update: see https://github.com/firefox-devtools/profiler/issues/2166#issuecomment-519577522. This is a quite involved bug.

digitarald avatar Jul 19 '19 13:07 digitarald

It looks like instead of just an array of values, it's an array of values inside of an object, with the key traceEvents. I think we may only need to teach it about { traceEvents: [...]}

https://github.com/firefox-devtools/profiler/blob/3067dda9cbf5807948aef149e18caf4e8870ed25/src/profile-logic/import/chrome.js#L72-L85

Here we would need teach it about traceEvents. Then in the import code we would need to handle the events being in traceEvents.

https://github.com/firefox-devtools/profiler/blob/3067dda9cbf5807948aef149e18caf4e8870ed25/src/profile-logic/import/chrome.js#L87-L92

I'm marking this as "good first issue". If I'm wrong about this assumption, then it won't be a good first issue, but it's worth trying!

Note that we would probably also want a test for this change.

gregtatum avatar Jul 19 '19 16:07 gregtatum

Hey @gregtatum ! Can I give this a try?

rbrishabh avatar Jul 21 '19 05:07 rbrishabh

@gregtatum , are these the two changes that I was supposed to make?

If yes, can you please let me know how I can test it?

profiler-1

profiler-2

If no, what else am I supposed to do? Thanks!

rbrishabh avatar Jul 21 '19 18:07 rbrishabh

If this issue is not assigned to anyone I would love to contribute.

sudonitin avatar Jul 21 '19 18:07 sudonitin

hey @globefire, thanks for the offer but let's focus on the other issue first!

julienw avatar Jul 29 '19 16:07 julienw

@rbrishabh I think that your changes could make it work with this format, but would make the other format (the performance devtool format) fail. With the intended change we want both formats work.

In short:

  • devtools' format is an array of things
  • about:traces fromat seems to be the same array of things inside an object with the traceEvents property.

So the work on this bug is to make the second case work, but still have the first case work.

In isChromeProfile, this could be like this:

  • is it an array? => Good
  • otherwise, is there a traceEvents property, and is it an array? => Good
  • otherwise, nope Then from the array, does the light check on this first element of the array.

Then in convertChromeProfile, do something similar.

Is that clearer? Please ask if you need anything more!

julienw avatar Jul 29 '19 17:07 julienw

Hey @julienw !

I think you made it quite clear.

Here's another attempt to solving this issue:

sol1

sol2

Does this hit anywhere close to home?

Also do I need to change anything else in the convertChromeProfile method?

Thanks!

rbrishabh avatar Aug 01 '19 04:08 rbrishabh

Hey @rbrishabh, in convertChromeProfile you need to do something similar to define the event object that is handled. I also suggest that you try to actually run the code too :) Thanks!

julienw avatar Aug 01 '19 10:08 julienw

I also suggest that you try to actually run the code too :)

Hey! I am actually running the code, but I am not sure how I can check the code for this particular bug?

Edit: I am not sure how to check these changes that I am making.

How do I go about that?

Thanks!

rbrishabh avatar Aug 01 '19 10:08 rbrishabh

Ah, that's a good question to ask!

The initial comment has a link to an example file you can load from the home page, this will be to test chrome's about:traces export format.

For Chrome's other format, we have another file in src/test/fixtures/upgrades/test.chrome.gz that you can use for testing. Ideally it would be a good idea to add the about:traces file to our fixtures and write a test with it too :)

Thanks!

julienw avatar Aug 01 '19 11:08 julienw

After making some changes, the test.chrome.gz still works just fine.

However, when trying to test about:traces, the following error comes up:

image

I think it's because there aren't any threads in the profile, and the bug is now solved, but I am not sure.

The error is no longer this :

Error: "Unserializing the profile failed: TypeError: e.meta is undefined"
    $i process-profile.js:1149
    hl receive-profile.js:892

Am I headed in the correct direction?

Thanks!

rbrishabh avatar Aug 04 '19 05:08 rbrishabh

Can you please push your existing code to a draft PR so that I can look at it? Thanks!

julienw avatar Aug 05 '19 15:08 julienw

Can you please push your existing code to a draft PR so that I can look at it? Thanks!

That's what I wanted to talk about.

Since before pushing, all the tests are ran, and I have written some code along the lines of --

if (
   !Array.isArray(profile) &&
   'traceEvents' in profile &&
   !Array.isArray(profile.traceEvents)
) {

I get this error multiple times-

Cannot get profile.traceEvents because property traceEvents is missing in mixed [1].

 [1]  92| export function convertChromeProfile(profile: mixed): Promise<Profile> {
        :

And I am unable to push. I don't quite understand the error as well. As soon as I use profile.traceEvents anywhere in the code, I am unable to push.

Do I force push and create a PR? If not, how do I go about these errors?

Thanks!

rbrishabh avatar Aug 05 '19 17:08 rbrishabh

Yes please force push :) Thanks

julienw avatar Aug 05 '19 17:08 julienw

I think it's because there aren't any threads in the profile, and the bug is now solved, but I am not sure.

I think that is true that the passed json file in the first comment doesn't have a profile information (no "event" is called ProfileChunk to start with).

This looks more like a log, so we could maybe convert this into markers. But not everything looks like markers either. There are pid/tid information so we could generate empty threads out of this instead of relying on ProfileChunk events. All this to say that this will need some more work than just reusing the existing code. @rbrishabh please tell me if you want to work on this, but my undersanding is that this is pretty difficult.

Also because the one from the first comment seems to be a react native trace, here is another example I just generated from Chrome: trace_test.json.gz

julienw avatar Aug 08 '19 15:08 julienw

Hello @julienw please can i work on this?

Cheederah avatar Oct 16 '20 20:10 Cheederah

@Cheederah assigning to you. Let us know if you need something!

canova avatar Oct 19 '20 08:10 canova

@julienw in your previous comment you stated that more work needs to be done, please can you provide details of what needs to be done? because it seems like the PR of the previous contributor on this issue was closed.

Cheederah avatar Oct 19 '20 11:10 Cheederah

Hi @Cheederah, after discussing this, we've realized that actually this issue is a lot more involved than we initially thought. Sorry about that. Would you mind working on another issue? You can ping me on matrix and we can try to figure out a suitable issue if you want.

canova avatar Oct 20 '20 16:10 canova

Alright, thank you!

Cheederah avatar Oct 20 '20 16:10 Cheederah

@canova while trying to load in a profile from my local dev environment, I get this error. Searching for the answer on google brought me here. 2 It seems the issue has not been solved just yet

ghost avatar Oct 22 '20 06:10 ghost

Worth noting that Chrome traces (which are also produced by the invaluable clang -ftime-trace) can be viewed via https://ui.perfetto.dev.

Trass3r avatar Oct 06 '22 15:10 Trass3r