Skip to content

[BUG] dash-renderer 4.0: O(n²) dependency graph resolution causes 8-9 second freeze in Firefox with ~400 callbacks #3661

@mbworth

Description

@mbworth

Describe your context

dash                      4.0.0
dash_ag_grid              32.3.2
dash-bootstrap-components 2.0.4
dash-bootstrap-templates  2.1.0
dash_daq                  0.6.0
dash-extensions           2.0.4
dash-iconify              0.1.2
dash-leaflet              1.1.3
dash-loading-spinners     1.0.3
dash_mantine_components   2.3.0
dash-svg                  0.0.12
  • OS: Windows 11
  • Browser: Firefox (latest stable), also tested in Chrome
  • Chrome handles the same app without noticeable delay

Describe the bug

Our production app registers ~400 callbacks (~150 using pattern-matching with ALL/MATCH). On page load, the _dash-dependencies response is 332kB. All network requests complete within 1.3 seconds, but there's an 8-9 second freeze before the first _dash-update-component POST fires. The entire delay is client-side JavaScript execution in the dash-renderer.

A Firefox profiler capture shows the content thread burning 36.68 seconds of CPU during this window. The hot functions are all in the dependency graph builder:

Samples Function
2071 (27.8%) forEach
1857 (24.9%) Tn
1826 (24.5%) Ln/<
1799 (24.2%) some
1788 (24.0%) Tn/<
1768 (23.8%) map
79 (1.1%) addDependency

The forEach/some/map nesting pattern and the presence of addDependency suggest O(n²) behavior in the callback dependency graph resolution — for each callback, it appears to check against all others.

Chrome's V8 engine handles the same workload fine, which suggests Firefox's SpiderMonkey doesn't optimize these particular loop patterns as aggressively. That said, 400 callbacks shouldn't require 37 seconds of CPU in any browser.

Expected behavior

The dependency graph for ~400 callbacks should resolve in under 1 second. The current implementation appears to scale quadratically — this will become a bigger problem as apps grow.

Steps to reproduce

Any Dash 4 app with ~400+ callbacks, especially with heavy use of pattern-matching IDs (ALL/MATCH), loaded in Firefox. Chrome masks the issue due to engine-level optimizations, but the underlying algorithmic complexity is the same.

Additional context

HAR file confirms the timeline: all assets and _dash-dependencies load by 1.3s, then nothing happens until 9.3s when the first callback POST fires. The gap is pure JS execution. Happy to share the Firefox profiler capture and HAR if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions