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

Flickering on Windows when using bubbletea >=0.26.0 #1019

Closed
supleed2 opened this issue May 14, 2024 · 2 comments · Fixed by #1021
Closed

Flickering on Windows when using bubbletea >=0.26.0 #1019

supleed2 opened this issue May 14, 2024 · 2 comments · Fixed by #1021
Labels

Comments

@supleed2
Copy link

Describe the bug
I tried updating to Bubbletea v0.26.0 (and also .1/.2) but the output seems to flicker a lot when running on Windows.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS: Windows 11 Build 22621
  • Shell: Powershell Core (also tried on cmd)
  • Terminal Emulator: Windows Terminal (also tried on Wezterm)
  • Terminal Multiplexer: None

To Reproduce
I don't have a minimal reproducible example yet, but noticed this while updating dependencies on my project, linked below. Specifically the client binary which uses bubbletea for the UI.

Source Code
Available here: supleed2/go-chat

Expected behavior
Stable output as with v0.25.0, observed with binaries available at: https://github.com/supleed2/go-chat/releases/tag/v0.1.2

Ideally with the new ability to resize :)

Screenshots
GIF to demonstrate:

clip

@meowgorithm
Copy link
Member

meowgorithm commented May 16, 2024

Okay awesome, thanks for reporting this. There's seems to be a bug in Windows where going in and out of the altscreen will incorrectly fire off a WindowResizeMsg. This wasn't the case in prior versions of Bubble Tea because resize events weren't possible.

In your case the flickering is happening because of this line, which seems to have been left in by mistake:

diff --git a/client/main.go b/client/main.go
index b8fe61a..37b8bd7 100644
--- a/client/main.go
+++ b/client/main.go
@@ -246,7 +246,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			m.input.Reset()
 		}
 	case tea.WindowSizeMsg:
-		clCmd = tea.Sequence(tea.ExitAltScreen, tea.EnterAltScreen)
 		m.history.Height = msg.Height - 2
 		m.history.Width = msg.Width
 		m.history.GotoBottom()

Of course, WindowSizeMsgs shouldn't be fired off at all during altscreen toggles, so we'll also make the corrections in Bubble Tea.

aymanbagabas added a commit that referenced this issue May 16, 2024
On Windows, changing the alt-screen-buffer triggers a window-size-event.
This might cause issues with some applications. Cache the last
window-size-event and compare before sending it the model.

Fixes: #1019
@supleed2
Copy link
Author

🤦 I just have to say thank you so much for digging through and noticing what was wrong with my code.

Yes that was left in, from a previous attempt where I thought maybe exiting and re-entering altscreen would cause new Height/Width values to be used.

Just tested removing the line and yep, works exactly as expected, including resizing! ❤️

aymanbagabas added a commit that referenced this issue May 17, 2024
On Windows, changing the alt-screen-buffer triggers a window-size-event.
This might cause issues with some applications. Cache the last
window-size-event and compare before sending it the model.

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

Successfully merging a pull request may close this issue.

2 participants