Skip to content

Commit e054524

Browse files
committed
Damage events are now emitted directly after parsing PTY data, ensuring proper batching
1 parent a78f476 commit e054524

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

docs/docs/releases.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ language: 'en'
99

1010
- TBD.
1111

12+
## 0.2.26
13+
14+
- **Fix frame dropping in release builds**: Fixed an issue where release builds would drop frames due to damage event timing
15+
- Damage events are now emitted directly after parsing PTY data, ensuring proper batching
16+
- Removed redundant Wakeup event mechanism that was causing multiple renders per update
17+
- Synchronized update timeouts now properly emit damage events
18+
- Significantly improves rendering smoothness in optimized builds
19+
1220
## 0.2.25
1321

1422
- Fix: Rio doesn't launch from context menu on Windows.

frontends/rioterm/src/application.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -226,36 +226,6 @@ impl ApplicationHandler<EventPayload> for Application<'_> {
226226
}
227227
}
228228
}
229-
RioEventType::Rio(RioEvent::Wakeup(route_id)) => {
230-
if let Some(route) = self.router.routes.get_mut(&window_id) {
231-
let context_manager = route.window.screen.ctx_mut();
232-
let grid = context_manager.current_grid_mut();
233-
234-
let mut request_pending_redraw = false;
235-
236-
for (_key, grid_context) in grid.contexts().iter() {
237-
let ctx = grid_context.context();
238-
239-
// In this case we know we have to render something that's pending.
240-
if ctx.renderable_content.pending_update.is_dirty() {
241-
request_pending_redraw = true;
242-
}
243-
244-
if let Some(terminal) =
245-
grid_context.context().terminal.try_lock_unfair()
246-
{
247-
// Only emit damage event if there's actual damage
248-
if terminal.peek_damage_event().is_some() {
249-
terminal.emit_damage_event();
250-
}
251-
}
252-
}
253-
254-
if request_pending_redraw {
255-
route.schedule_redraw(&mut self.scheduler, route_id);
256-
}
257-
}
258-
}
259229
RioEventType::Rio(RioEvent::TerminalDamaged { route_id, damage }) => {
260230
if self.config.renderer.strategy.is_event_based() {
261231
if let Some(route) = self.router.routes.get_mut(&window_id) {

frontends/rioterm/src/renderer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ impl Renderer {
858858
Some(snapshot) => snapshot,
859859
None if force_full_damage => {
860860
// Force full damage case - create a fresh snapshot
861-
let mut terminal = context.terminal.lock();
861+
let terminal = context.terminal.lock();
862862
let snapshot = TerminalSnapshot {
863863
colors: terminal.colors,
864864
display_offset: terminal.display_offset(),

rio-backend/src/performer/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ where
206206
// Parse the incoming bytes.
207207
state.parser.advance(&mut **terminal, &buf[..unprocessed]);
208208

209+
// Emit damage event if there's any damage after parsing
210+
if terminal.peek_damage_event().is_some() {
211+
terminal.emit_damage_event();
212+
}
213+
209214
processed += unprocessed;
210215
unprocessed = 0;
211216

@@ -217,8 +222,8 @@ where
217222

218223
// Queue terminal update processing unless all processed bytes were synchronized.
219224
if state.parser.sync_bytes_count() < processed && processed > 0 {
220-
self.event_proxy
221-
.send_event(RioEvent::Wakeup(self.route_id), self.window_id);
225+
// Damage events are now emitted directly after parsing
226+
// No need to send Wakeup events
222227
}
223228

224229
Ok(())
@@ -343,9 +348,14 @@ where
343348

344349
// Handle synchronized update timeout.
345350
if events.is_empty() && self.receiver.peek().is_none() {
346-
state.parser.stop_sync(&mut *self.terminal.lock());
347-
self.event_proxy
348-
.send_event(RioEvent::Wakeup(self.route_id), self.window_id);
351+
let mut terminal = self.terminal.lock();
352+
state.parser.stop_sync(&mut *terminal);
353+
354+
// Emit damage event if there's any damage after processing sync buffer
355+
if terminal.peek_damage_event().is_some() {
356+
terminal.emit_damage_event();
357+
}
358+
drop(terminal);
349359

350360
continue;
351361
}

0 commit comments

Comments
 (0)