Skip to content

Make each streamed draft update cheaper to commit on mobile #1839

Closed as duplicate

Description

@DoodleBears

Problem. After #1811 the mobile DM keeps up with a streamed reply, and React only re-renders the growing tail of the draft (0 MessageBubble renders per draft update, 3–4 BlockView renders per update). But each draft update still costs about 120 ms of JS. So the draft redraws about 4 times a second, although draftDelayMs (50 ms) allows 20. JS stays 40–47% busy during a stream.

Evidence (iOS 18.6 simulator, dev build, the same 1,680-word reply replayed at a fixed rate, 3 runs with apps/mobile/scripts/rn-profile.mjs):

  • Fabric completeRoot / replaceContainerChildren: 34% of JS self time (9.6–9.9 s per ~56 s stream).
  • React DEV console.createTask: about 20%. It does not exist in release builds.
  • GC: about 5%. No app function is in the top 40.
  • 226–237 frames over 50 ms per stream, longest 0.8–1.2 s.
  • Not measured: UI-thread FPS and native dropped frames.

Proposal.

  1. Measure first, as in Profiling:
    • Add a release-build (or __DEV__ = false) run, so the DEV overhead is removed from the numbers.
    • Add UI-thread frame timing, for example with xctrace.
  2. Then reduce the cost of each native commit for the draft. Options to compare:
    • Keep the growing tail block's host view tree small (for example one Text per block instead of nested inline views).
    • Split the tail block so finished lines stop changing.
    • Adapt the draft redraw rate to the measured commit cost.
  3. Record before and after numbers in the PR.

Done when: in a release build, a draft update's JS cost is well under one frame budget, and the stream shows no frames over 50 ms on the reference scenario.

Refs #1811

Activity

  1. DoodleBears commented on Oct 14, 2026

    @DoodleBears
    ContributorAuthor

    Agent work claim

    • Agent: Claude Code
    • Task: claude-code/local/03081932-a680-44a7-bb8e-76677b7b0c7b (not a DSH Session)
    • Issue scope: render chat Markdown with react-native-enriched-markdown (native text), streaming drafts closed with remend; A/B profile against main
    • Branch: claude/1839-enriched-markdown
    • Started: 2026-10-14 21:45 UTC
    • State: active
  2. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 14, 2026
  3. DoodleBears commented on Oct 14, 2026

    @DoodleBears
    ContributorAuthor

    Task claude-code/local/03081932-a680-44a7-bb8e-76677b7b0c7b: handed off. This issue was closed as a duplicate; the work continues under #1838 / #1804 on branch claude/1838-enriched-markdown.

  4. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 14, 2026
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