Skip to content

Rewrite on_process_idle_events() as an async idle task #791

@lionel-

Description

@lionel-

Right now plot requests are handled at idle time when no user executions are running in the console:

unsafe { Self::process_idle_events() };

The current way we poll for the messages is timeout-based, with a freq of 200ms at the time of writing. This approach translates to visible delays in the frontend when a plot needs to be rerendered. I'm about to reduce the frequency to 50ms but ideally we wouldn't wait at all when a request is ready.

To fix this, we could spawn an async idle task with r_task::spawn_idle() that runs an infinite loop selecting on the plot comm channels. This would involve:

  • Switching to tokio async channels instead of sync crossbeam channels.
  • Setting things up so that is_drawing and should_render causes the task to wait until the graphics device is ready to render.

This approach will improve overall performance of the communication between the frontend and Ark for plots (part of posit-dev/positron#5184).

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