Fix UI hang when loading data for 0 or negative canvas sizes (#1563) The `calculateResolution` function is used to work out the horizontal resolution at which data should be loaded for a given timespan and horizontal width (e.g. of a canvas) in px. If either of these values are 0 or negative, this function currently returns 1n. This causes issues as loading data at a resolution of 1 is rarely what you actually want to do in this instance, and it usually produces very slow queries which can cause the UI to hang and generally become unresponsive. This patch makes `calculateResolution` return a `Result<bigint>` type instead, and returns an error value when the inputs are 0 or negative. Using a `Result<T>` type rather than throwing an error forces callers to handle the error case at the callsite so it cannot be ignored. In this case, if resolution cannot be caulculate then it's safe to skip rendering, and the callsites have been modified to do so. Fixes: https://b.corp.google.com/issues/418232042
Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.
See https://perfetto.dev/docs or the /docs/ directory for documentation.