google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)

Home Page:https://www.perfetto.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading trace input file as URL attribute

DoronRippel opened this issue · comments

AFAIK - Perfetto can load a trace file only from the menu.
Is there a way to load it upon starting directly from the URL, something such as:
GET https://ui.perfetto.dev/load?file_name=my_trace.json
This could be great for systems that a user can test by calling an endpoint on the system, which will return a trace file that will be automatically opened for the user in Perfetto without the need to download the trace file, then opening Perfetto then manually selecting the file to load.
Another alternative - a POST endpoint on Perfetto that will accept in the body the complete trace file in some format.

something such as: GET https://ui.perfetto.dev/load?file_name=my_trace.json

Unfortunately what you ask is unfeasible due to the security model of browsers. There is no way to do file-based access without browser-mediation via the "open file" dialog. If you think about that, it would be a big security issue if that was possible.

It is possible instead of specifying a url, see what https://cs.android.com/android/platform/superproject/+/master:external/perfetto/tools/open_trace_in_ui does

Another alternative - a POST endpoint on Perfetto that will accept in the body the complete trace file in some format.

A POST is not feasible because Perfetto has - by design - no server-side component. This is so users can be guaranteed that their traces are only processed locally and are NOT sent to any google server. Local-only HTML+JS code cannot see POST. Instead something similar to what you ask is possible via window.open() + postmessage.

See https://perfetto.dev/docs/visualization/deep-linking-to-perfetto-ui