Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGB / 24 bit true color glitching / blinking in macOS terminal.app #475

Closed
nx10 opened this issue Sep 8, 2023 · 9 comments
Closed

RGB / 24 bit true color glitching / blinking in macOS terminal.app #475

nx10 opened this issue Sep 8, 2023 · 9 comments
Labels
Status: Wontfix This will not be worked on. This might be due to time, intended behavior, or undesirable changes Type: Bug Something isn't working

Comments

@nx10
Copy link

nx10 commented Sep 8, 2023

Issue Status

macOs terminal does not support TrueColor. This will be documented in the Color::Rgb docs (as of PR #477)

Original issue text:


Description

Colors are not working properly in macOS system terminal. I am using crossterm as a backend.

To Reproduce

Something like this when drawing the buffer

let fg = tui::style::Color::Rgb(123, 312, 22); // any color
let bg = tui::style::Color::Rgb(123, 22, 312); // any color
buf.get_mut(0, 0).set_char('▄').set_fg(fg).set_bg(bg);

Expected behavior

Instead of showing the correct colors as expected the whole buffer looks weird and blinks (see video below).

Screenshots

This is a video of a ratatui application where most of the buffer is constructed like in the example above.

Screen.Recording.2023-09-08.at.12.13.57.PM.mov

Same terminal with font "SF Mono Regular 11" (System default) so it does not seem to be a font issue

image

This is what it looks like in ITerm2 on the same machine (and in every other terminal I tried on linux + windows)

image

Environment

  • OS: macOS Ventura 13.5 (M2)
  • Terminal Emulator: macOS system terminal (Version 2.13 (447))
  • Font: Monaco 18
  • Crate version: 0.23.0
  • Backend: crossterm
@nx10 nx10 added the Type: Bug Something isn't working label Sep 8, 2023
@joshka
Copy link
Member

joshka commented Sep 8, 2023

Do you know if this Is this just the Rgb colors or all colors?
Can you run the colors example and post the output? (I'll add a second view that shows RGB)

As a side note, looking at the image you're displaying (very cool btw), you might be interested in https://crates.io/crates/ratatu-image by @benjajaja

@joshka
Copy link
Member

joshka commented Sep 9, 2023

Using the new colors example from #476 I am able to repro this:

image expected (iterm2): image

@joshka
Copy link
Member

joshka commented Sep 9, 2023

Raised the issue upstream at crossterm-rs/crossterm#819

@joshka
Copy link
Member

joshka commented Sep 9, 2023

The root cause is that Terminal.app doesn't support TrueColor.
https://discussions.apple.com/thread/250459018
https://discussions.apple.com/thread/250636611

Same problem in Termion. Interestingly Termwiz uses an approach that falls back to an ANSI color on non true color enabled terminals, which is neat.

@joshka joshka changed the title Colors not working properly in macOS system terminal (crossterm) RGB / 24 bit true color glitching / blinking in macOS terminal.app Sep 9, 2023
@joshka joshka added the Status: Wontfix This will not be worked on. This might be due to time, intended behavior, or undesirable changes label Sep 9, 2023
@joshka
Copy link
Member

joshka commented Sep 9, 2023

Because this is something out of our hands (it would require a fix in Terminal.app, the best we can do with this for now is document it - see #477.

Neither Crossterm or Termion expose information on the terminal capabilities to be able to detect if this is a problem, and the Termwiz backend just falls back to the default text color (which is not ideal and perhaps worth fixing if someone wants to do this).

Closing this out as wontfix, but there may be other non-obvious approaches to detecting this that could be worth pursuing if you absolutely need this (i.e. manually checking the terminal capabilities and providing the user with an alternative palette).

@joshka joshka closed this as completed Sep 9, 2023
@nx10
Copy link
Author

nx10 commented Sep 9, 2023

Thank you so much for the quick response and figuring this out!

I will likely try to use terminfo to query capabilities and then either map true color to what is available or abort with a user understandable message.

For context I am building a 3D volumetric viewer for brain imaging / neuroscience. We often want to quickly check what our data looks like on remote clusters and inside containers where we are only connected via a terminal. Ratatui made prototyping this a breeze so thank you and all other conributers a lot!

@joshka
Copy link
Member

joshka commented Sep 9, 2023

If you do want a bit of a head start on this, it's worth taking a look at the termwiz source code. In particular: https://github.com/wez/wezterm/blob/main/termwiz/src/caps/mod.rs

@nx10
Copy link
Author

nx10 commented Sep 9, 2023

Seeing the amount of edge cases in this makes me wonder if I should switch to the termwiz backend alltogether until crossterm implements (color) capability querying. But thanks in any case for the pointers!

@joshka
Copy link
Member

joshka commented Sep 9, 2023

Perhaps, but do take note that it hasn't been used anywhere near as much as the other backends, so you're swapping known unknowns for unknown unknowns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Wontfix This will not be worked on. This might be due to time, intended behavior, or undesirable changes Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants