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
3 files changed
tree: 2b592c9cfe44c2aecc6d26f53da4c85330a07199
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. python/
  13. src/
  14. test/
  15. third_party/
  16. tools/
  17. ui/
  18. .bazelignore
  19. .bazelrc
  20. .bazelversion
  21. .clang-format
  22. .clang-tidy
  23. .git-blame-ignore-revs
  24. .gitallowed
  25. .gitattributes
  26. .gitignore
  27. .gn
  28. .style.yapf
  29. .yapfignore
  30. Android.bp
  31. Android.bp.extras
  32. BUILD
  33. BUILD.extras
  34. BUILD.gn
  35. CHANGELOG
  36. codereview.settings
  37. DIR_METADATA
  38. heapprofd.rc
  39. LICENSE
  40. meson.build
  41. METADATA
  42. MODULE.bazel
  43. MODULE.bazel.lock
  44. MODULE_LICENSE_APACHE2
  45. OWNERS
  46. perfetto.rc
  47. perfetto_flags.aconfig
  48. PerfettoIntegrationTests.xml
  49. persistent_cfg.pbtxt
  50. README.chromium
  51. README.md
  52. TEST_MAPPING
  53. traced_perf.rc
  54. WATCHLISTS
  55. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

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.