Repository navigation
Commit f822a07
authored
icy_term: keep up with streamed sixel video (#191)
* Leave the scrollback out of the render snapshot
TextScreen::render_snapshot() cloned the whole screen, scrollback
included, and each scrollback line keeps a rendered pixel strip
(640x16 RGBA, about 40 KB). With the default 2000 lines full, every UI
frame copied about 80 MB while holding the screen lock: 39 ms per
frame. The terminal thread waited for the lock long enough to drop
from about 28 to about 15 sixel frames a second, so a 20 fps sixel
stream fell further and further behind.
The renderer never reads the scrollback (viewing it goes through
snapshot_scrollback()), so the snapshot now copies everything else and
starts with an empty scrollback. Time under the lock per frame drops
to 0.16 ms.
* Skip the sixel display pause when a newer sixel is queued
The terminal thread sleeps 20 ms after each sixel so the UI can show
every frame of an animation. On Windows that sleep takes about 31 ms,
while decoding a 460x360 frame takes under 1 ms, so the pause caps a
sixel stream at about 28 frames a second however far behind the
terminal is. Over SSH nothing slows the host down, so the lag then
grows without limit.
On a live connection the pause is now skipped when the host has
already sent a newer sixel. Every frame is still decoded and placed;
the UI shows the newest one, the way SyncTERM and xterm degrade. When
the terminal keeps up, and for local playback, every frame still gets
its pause, so sixel animations are unchanged.
* Don't pause after sixels on a live connection
The 20 ms pause after each sixel lets the UI show every frame of an
animation played back locally. On a connection the host paces its own
frames, and the pause only costs time: NESDOOR streams NES video at
up to 60 frames a second, and the terminal thread spent about 80% of
each second asleep in these pauses. It ran at the very edge of the
stream, fell behind on every burst, and keystrokes waited behind the
pauses too.
The previous change skipped the pause only when a newer sixel was
already queued, which does not help when frames arrive one per read.
The pause now applies only without a connection, as in SyncTERM and
xterm, which draw sixels as fast as they arrive.
* Process received data in the tick that reads it
Each tick processed what was already pending and only then read from
the connection, so new data waited a full tick (about 13 ms) before
it reached the screen. Process it right after the read instead.
With baud emulation the second pass releases nothing until enough time
has passed, so emulated speeds are unchanged.1 parent 846b5b4 commit f822a07
3 files changed
Lines changed: 106 additions & 20 deletions
File tree
- crates
- icy_engine
- src/text_buffer
- tests
- icy_term/src/terminal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1529 | 1529 | | |
1530 | 1530 | | |
1531 | 1531 | | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
| 700 | + | |
718 | 701 | | |
719 | 702 | | |
720 | 703 | | |
| |||
772 | 755 | | |
773 | 756 | | |
774 | 757 | | |
| 758 | + | |
| 759 | + | |
775 | 760 | | |
776 | 761 | | |
777 | 762 | | |
| |||
780 | 765 | | |
781 | 766 | | |
782 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
783 | 790 | | |
784 | 791 | | |
785 | 792 | | |
| |||
1768 | 1775 | | |
1769 | 1776 | | |
1770 | 1777 | | |
1771 | | - | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
1772 | 1784 | | |
1773 | 1785 | | |
1774 | 1786 | | |
| |||
3161 | 3173 | | |
3162 | 3174 | | |
3163 | 3175 | | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
3164 | 3218 | | |
3165 | 3219 | | |
3166 | 3220 | | |
| |||
0 commit comments