firefox-devtools/profiler

无法读取或解析其中的分析记录。

Opened this issue · 14 comments

无法读取或解析其中的分析记录。

Error: Unserializing the profile failed: SyntaxError: Unexpected token '', ""... is not valid JSON

The full stack has been written to the Web Console.

you can get the souce perf data from me,the file can be viewed by perf report. Can i use the other version profiler to retry.
last Fri. i use it fine.

┆Issue is synchronized with this Jira Task

Can you please put the data somewhere to download?
thanks!

Can you please put the data somewhere to download? thanks!

it‘s my duty but shame that the data include some secrets of my program really important.
i try to make a simple cpp case, but can not replay the question.

Please send privately to julien at mozilla.com if you prefer

Please send privately to julien at mozilla.com if you prefer
Can i have some way to Revert profiler tool to last Fri. to verify it's the chenge between this days?

Yes; you can always clone the repository, go back to an older version with git, and run it locally!
Instructions are in our README: https://github.com/firefox-devtools/profiler?tab=readme-ov-file#development

Our last deploy was 1 month ago, but it's always possible you were running an older version (because of how service workers work).
But I don't think we touched this code recently. More likely we have a bug, possibly because we don't recognize your file as a perf file. If you're curious, this is our code to detect a perf file:

/**
* The "perf script" format is the plain text format that is output by an
* invocation of `perf script`, where `perf` is the Linux perf command line tool.
*/
export function isPerfScriptFormat(profile: string): boolean {
// We can have two different types of perf script files:
// Files with header and files without header.
//
// The header, if present, looks like this (generated here [1]):
//
// # ========
// # captured on : Mon Aug 30 11:15:28 2021
// # header version : 1
// # data offset : 336
// # data size : 31672
// # feat offset : 32008
// # hostname : somehost
// # os release : 5.10.40-amd64
// # ========
// #
//
// Then the first sample begins. Each sample starts with a line containing the
// thread name, tid/pid, and timestamp.
// eg, "V8 WorkerThread 24636/25607 [000] 94564.109216: cycles:"
//
// If there's no header, the file starts with the first sample immediately.
//
// To detect these files, we detect the header if present, or the first line
// of the first sample if no header is present.
//
// [1] https://github.com/torvalds/linux/blob/20cf903a0c407cef19300e5c85a03c82593bde36/tools/perf/util/session.c#L2755-L2757
if (profile.startsWith('# ========\n')) {
return true;
}
if (profile.startsWith('{')) {
// Make sure we don't accidentally match JSON
return false;
}
// There was no header, so we need to match the first line of the first sample.
const firstLine = profile.substring(0, profile.indexOf('\n'));
// +- process name (anything before the rest of the regexp, can contain spaces)
// | +- PID/ (optional)
// | | +- TID
// | | | +- [CPU] (optional, present in SimplePerf output)
// | | | | +- timestamp
// vvvvv vvvvvvvvv vvv vvvvvvvvvvvvvv vvvvvv
return /^\S.*?\s+(?:\d+\/)?\d+\s+(?:\[\d+\]\s+)?[\d.]+:/.test(firstLine);
}

If you find a bug there, feel free to open a PR to fix it!

Indeed,during last fri to today, our soft stack has updated many, may be the new perf data caused to trigger a bug.

UnserializationError: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
ic process-profile.js:1768
process-profile.js:1796:12
ic process-profile.js:1796
Error: Unserializing the profile failed: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
ic process-profile.js:1797

the error occured here, is it useful for U?  For me, 'front-end' and 'JSON' are both completely new concepts.

No that doesn't help sadly.

Is it possible for you to share just the first 10 lines of your file?

No that doesn't help sadly.

Is it possible for you to share just the first 10 lines of your file?

Surely

$ head out.perf -n 20
kernelLaunch 477166 125805.874903:      40000 cpu-clock:
        ffffffff83255ee6 vmacache_update+0x6 ([kernel.kallsyms])
        ffffffff830809a4 do_user_addr_fault+0x114 ([kernel.kallsyms])
        ffffffff83081018 __do_page_fault+0x58 ([kernel.kallsyms])
        ffffffff8308107c do_page_fault+0x2c ([kernel.kallsyms])
        ffffffff83c01284 page_fault+0x34 ([kernel.kallsyms])
        ffffffff83ac1960 copy_user_generic_unrolled+0xa0 ([kernel.kallsyms])
        ffffffff8335989f load_elf_binary+0xccf ([kernel.kallsyms])
        ffffffff832e471b search_binary_handler+0x8b ([kernel.kallsyms])
        ffffffff832e59ee __do_execve_file.isra.0+0x4ee ([kernel.kallsyms])
        ffffffff832e5f39 __x64_sys_execve+0x39 ([kernel.kallsyms])
        ffffffff830044c7 do_syscall_64+0x57 ([kernel.kallsyms])
        ffffffff83c0008c entry_SYSCALL_64_after_hwframe+0x44 ([kernel.kallsyms])
            7f035175517b [unknown] ([unknown])

It's a shame that I open it in my home‘s PC(win11) successfully, but failed in my Company’s Laptop(win10), edge/chorme/firefox are all failed. what the infomations of envirenment should i provide to help U. Also, i get my perf data by,
sudo perf record -e cpu-clock -F 25000 -g ./myprogram and then sudo perf script -i perf.data > out.perf in my Linxu system, if i reduce the frequency from 25000 to 5000. It works ok! FYI!

The header looks good to me, this shouldn't go through this path...

By the way:

UnserializationError: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I notice that this isn't the same error as the first one:

Error: Unserializing the profile failed: SyntaxError: Unexpected token '', ""... is not valid JSON

Have you tried with different files, and they are all failing?
Are you saying that the same files are working on another computer? Or are you using the same process, and that is working on another computer?

sudo perf record -e cpu-clock -F 25000 -g ./myprogram and then sudo perf script -i perf.data > out.perf

This works for me.
I use linux-perf version 6.1.76 (from the debian package), my linux kernel is 6.7.9.
Could that make a difference? What linux perf version and what kernel version do you have?

  1. My System Version and perf tool version are shown as belowe:
$ uname -a
Linux S80 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ perf --version
perf version 5.4.44
  1. The error message Error: Unserializing the profile failed: SyntaxError: Unexpected token '', ""... is not valid JSON is shown in the browser pop-up window. The UnserializationError: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data is the same error shown in the debugging console in browser.

  2. The tests list belowe i have tested:

  • (1) Get the perf date of myprogram with frequency 6000,8000,10000,20000,25000 in my linux system. And try to view it in my win10 computer. Failed.
  • (2) The same as last test(1),but a simple cpp multi-thread app. Success.
  • (3) The same as (1), but the frequncy 5000. Success.
  • (4) The same as (1), but view the data in my home‘s win11 computer. Success.

Are you saying that the same files are working on another computer? Or are you using the same process, and that is working on another computer?

The same program,and get perf data by same command,Not same data. Then use a different computer to view the perf data.
Currently I have no way to verify the control variables on two computers. I will try to verify it next Monday.

I have tried to open the same perf data in different computer, and one of them success,but another failed.
The head of the xxx.perf is:

$ head out.perf -n 20
kernelLaunch 477408 126841.251264:      40000 cpu-clock: 
        ffffffff830809e6 do_user_addr_fault+0x156 ([kernel.kallsyms])
        ffffffff83081018 __do_page_fault+0x58 ([kernel.kallsyms])
        ffffffff8308107c do_page_fault+0x2c ([kernel.kallsyms])
        ffffffff83c01284 page_fault+0x34 ([kernel.kallsyms])
            7fd5ab240700 _dl_sysdep_start+0x0 (/usr/lib/x86_64-linux-gnu/ld-2.31.so)
            7fd5ab225108 _dl_start_user+0x0 (/usr/lib/x86_64-linux-gnu/ld-2.31.so)

kernelLaunch 477408 126841.251303:      40000 cpu-clock: 
        ffffffff83300076 __alloc_fd+0xe6 ([kernel.kallsyms])
        ffffffff83300110 get_unused_fd_flags+0x30 ([kernel.kallsyms])
        ffffffff832d9859 do_sys_open+0x119 ([kernel.kallsyms])
        ffffffff832d9a50 __x64_sys_openat+0x20 ([kernel.kallsyms])
        ffffffff830044c7 do_syscall_64+0x57 ([kernel.kallsyms])
        ffffffff83c0008c entry_SYSCALL_64_after_hwframe+0x44 ([kernel.kallsyms])
            7fd5ab242f68 __GI___open64_nocancel+0x38 (/usr/lib/x86_64-linux-gnu/ld-2.31.so)
            7fd5ab22cc16 open_path+0x1d6 (/usr/lib/x86_64-linux-gnu/ld-2.31.so)
            7fd5ab22e803 _dl_map_object+0x3a3 (/usr/lib/x86_64-linux-gnu/ld-2.31.so)

kernelLaunch 477408 126841.251343:      40000 cpu-clock: