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

[Bug] Resizing textarea causes white flashes on websites with dark color-scheme #1637

Closed
robinplace opened this issue Sep 25, 2024 · 2 comments · Fixed by #1638
Closed

[Bug] Resizing textarea causes white flashes on websites with dark color-scheme #1637

robinplace opened this issue Sep 25, 2024 · 2 comments · Fixed by #1638
Milestone

Comments

@robinplace
Copy link

robinplace commented Sep 25, 2024

Bacause of the imperfect nature of resize observers and such, Firenvim ends up relying on iframe transparency to prevent various visual glitches. It turns out that there's a subtle sharp corner in the iframe spec that causes this to break down under certain conditions related to the <meta name="color-scheme"/> tag. This blog post lays out the situation better than I can.

The real world impact is that on websites that use the color-scheme as part of their dark mode implementation, e.g. github, resizing textareas causes a white flash.

This could be solved either by setting a color-scheme meta tag inside the Firenvim iframe that matches that of the page or by adjusting the canvas resize process to be frame perfect. I'd be happy to implement either, though I'd like to ask a few questions of someone who knows the codebase better than I do before taking a pass myself.

Great extension btw!

@glacambre
Copy link
Owner

Hi, thanks for the bug report and linking to that article, it was a pretty interesting read :)

The best solution would probably indeed be to implement canvas resize to be frame perfect, but given the complexity of the resizing machinery in Firenvim, it's also the hardest approach.

I think the solution with the best result/effort ratio likely is to set the background color of the iframe's html document to the background color sent by Neovim. This will ensure that there is no user-visible boundaries, even when the user changes their colorscheme through Neovim or when their Neovim's colorscheme does not match the page's.

glacambre added a commit that referenced this issue Sep 25, 2024
Issue #1637 reports that resizing the underlying textarea of a Firenvim
iframe can result in flashes of color. This can be particularly visible
when using Firenvim with a dark colorscheme on Github in dark mode.

The reason for these flashes of color is that when resizing, the iframe
gets resized first and the Neovim canvas gets resized second, between
these two moments, the iframe's background color can become visible if
the CSS colorscheme of the iframe and of the website do not match.

We fix this by ensuring that the iframe's background color is set to the
background color of the Neovim colorscheme. This breaks the ability of
the iframe to turn transparent when unfocused (the iframe gets dimmed
instead), but given that multiple users complained about this feature,
it may not be such a bad change.

Closes #1637.
glacambre added a commit that referenced this issue Sep 25, 2024
Issue #1637 reports that resizing the underlying textarea of a Firenvim
iframe can result in flashes of color. This can be particularly visible
when using Firenvim with a dark colorscheme on Github in dark mode.

The reason for these flashes of color is that when resizing, the iframe
gets resized first and the Neovim canvas gets resized second, between
these two moments, the iframe's background color can become visible if
the CSS colorscheme of the iframe and of the website do not match.

We fix this by ensuring that the iframe's background color is set to the
background color of the Neovim colorscheme. This breaks the ability of
the iframe to turn transparent when unfocused (the iframe gets dimmed
instead), but given that multiple users complained about this feature,
it may not be such a bad change.

Closes #1637.
@glacambre glacambre added this to the Next milestone Sep 25, 2024
@glacambre
Copy link
Owner

Fixed on master, will be available once I publish a new release to the add-on stores (which is unlikely to happen soon, I think I can't upload new versions to the chrome store until Firenvim is ported to manifest v3...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants