posit-dev / posit-dev/positron

Notify backends of updates to plot render settings

Open
#7,449 0 comments 0 reactions 1 assignee View on GitHub

@lionel- is already working on this.

Since May 6, 2025.

area: plots
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

With #7247 we now expect backends to send pre-renderings of plots in comm_open messages. This makes the plots feel snappier as a version of new plots is displayed right away in the plot pane (see #5184). However, the experience is currently subpar for applications that run in the console for a long time while generating plots. In that case, all plots created while the area geometry is changing will use outdated render settings, causing distorted output.

This happens because the only time a backend can currently update the current render settings is during a render request. If the pre-rendering was not generated with up-to-date settings, the frontend sends a request right away. So in theory, the backend would soon be notified of the updated settings. However, since these render requests are comm messages queued on Shell, they must wait for all current and pending execute requests to finish before being handled by the backend. This is why long-running applications that generate plots do not behave properly: the updated settings are only received once the application has stopped.

Concretely, it should be possible to run this loop, change the plot pane size while the plots are being rendered, and get proper pre-renderings right away:

for (i in 1:20) {
  plot(i)
  Sys.sleep(1)
}

Also relevant for things like demo(graphics): Currently when the second plot is opens, the plot history strip appears and changes the plot render area. Subsequent plots are rendered with outdated settings.

To fix this:

  • We should send events/notifications to backends with updated render settings as soon as the plot pane area changes (now sent as requests but should become notifications, see #7448).

  • These notifications should be sent asynchronously (#7447). While an expression is running, we can't update the backend via a regular Shell message so all the following plots are rendered a little off and are only rerendered once the console stops being busy.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.