1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 11:17:15 +03:00

Improve UX when we run out of texture space

Rather than leaving the frame un-rendered, this commit arranges
to make one last pass but with all image quad assignments skipped.

This should at least make a reasonable effort at displaying text
on the screen.

refs: https://github.com/wez/wezterm/issues/879
This commit is contained in:
Wez Furlong 2021-08-01 11:20:10 -07:00
parent 94d409d340
commit 887152a13d
2 changed files with 26 additions and 7 deletions

View File

@ -223,6 +223,9 @@ pub struct TermWindow {
event_states: HashMap<String, EventState>,
has_animation: RefCell<Option<Instant>>,
/// We use this to attempt to do something reasonable
/// if we run out of texture space
allow_images: bool,
scheduled_animation: RefCell<Option<Instant>>,
gl: Option<Rc<glium::backend::Context>>,
@ -483,6 +486,7 @@ impl TermWindow {
event_states: HashMap::new(),
has_animation: RefCell::new(None),
scheduled_animation: RefCell::new(None),
allow_images: true,
};
let tw = Rc::new(RefCell::new(myself));

View File

@ -86,6 +86,8 @@ impl super::TermWindow {
// If nothing on screen needs animating, then we can avoid
// invalidating as frequently
*self.has_animation.borrow_mut() = None;
// Start with the assumption that we should allow images to render
self.allow_images = true;
let start = Instant::now();
@ -138,12 +140,21 @@ impl super::TermWindow {
};
if let Err(err) = result {
log::error!(
"Failed to {} texture: {}",
if pass == 0 { "clear" } else { "resize" },
err
);
break;
if self.allow_images {
self.allow_images = false;
log::info!(
"Not enough texture space ({:#}); \
will retry render with images disabled",
err
);
} else {
log::error!(
"Failed to {} texture: {}",
if pass == 0 { "clear" } else { "resize" },
err
);
break;
}
}
} else if err.root_cause().downcast_ref::<ClearShapeCache>().is_some() {
self.shape_cache.borrow_mut().clear();
@ -260,7 +271,7 @@ impl super::TermWindow {
},
);
if pos.index == 0 {
if pos.index == 0 && self.allow_images {
// Render the window background image
if let Some(im) = self.window_background.as_ref() {
let mut quad = quads.allocate()?;
@ -1214,6 +1225,10 @@ impl super::TermWindow {
hsv: Option<config::HsbTransform>,
glyph_color: LinearRgba,
) -> anyhow::Result<()> {
if !self.allow_images {
return Ok(());
}
let padding = self
.render_metrics
.cell_size