Skip to content

The whole chart travels over the Shiny websocket on every flush; session.dynamic_route would serve it out of band #534

Description

@jooyoungseo

#454 listed three ways to stop maidr.render() hurting a Shiny app. Option 1 (render off the loop, per-figure lock) shipped in #504 and #531, option 3 (document it accurately) shipped in #511, and #454 is now closed on that basis.

Option 2 never happened, and it addresses a different cost. Splitting it out so it is tracked somewhere that is still open — docs/index.qmd currently points a reader at #454 for it, which is a closed issue.

The cost

Every reactive flush pushes the entire rendered chart through the websocket as part of the output payload:

  • roughly 25 KB per flush on the default use_cdn setting
  • ~1.9 MB per chart with use_cdn=False, because the bundle is inlined into each srcdoc

Measured under the #457 QA with two charts on one page, offline: 3891 KB for the iframe build against 44 KB for an inline one. The gap widens with every chart, since each iframe carries its own copy of the bundle.

This is per flush, not per session. A reader moving a slider pays it again each time.

The shape

session.dynamic_route registers a URL for the duration of a session. The output payload becomes a reference rather than the document, and the browser fetches the chart — cached, out of band, off the websocket.

Worth knowing before anyone starts:

  • It changes what render_maidr returns, so tests/widget/test_every_door_agrees.py is the contract to keep honest — every door must still ship the same chart.
  • It interacts with the iframe question in Evaluate rendering Shiny charts inline instead of inside an iframe #457. An inline chart already avoids most of this (44 KB vs 3891 KB) by loading the bundle once per page rather than once per chart; a dynamic route would help both embeddings but is a smaller win for the inline one.
  • The bundle and the chart are separable: use_cdn=False weight is the bundle, and use_cdn="auto" has no working offline fallback inside a srcdoc iframe #455 is about giving that an offline path that is not "inline it per chart". Fixing that could shrink this on its own.

No measurements of a dynamic_route implementation here — this issue exists so the idea has a home and the docs have something open to point at.

Follow-up from #454.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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