mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #909] Windows Non-Stop Flickering when calling function QueueUpdateDraw() inside SetAfterDrawFunc() #661
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#661
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Vinrithi on GitHub (Nov 1, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/909
Hello. I would like to appreciate you for the wonderful work you've done in providing this library. I had started using it in 2022 in a small project and noticed there were new updates. However, there seems to be a bug which causes the application to flicker non-stop in Windows in the latest release v0.0.0-20231031172508-2dfe06011790. I updated from v0.0.0-20220812085834-0e6b21a48e96. I've created a sample code below to showcase this.
screen-capture.webm
The above video shows what is happening in the UI and this is the code:
This only happens when I call
and it only happens in Windows. I've tried in Command Prompt and Powershell latest 7.3.9 and the output is the same. In Linux there is no issue whatsoever. The application is running as expected. In my actual project, Before the latest updates, the flickering was not happening:
go.mod before
go.mod updated
In my actual project, I need to call the function to redraw the UI for smooth operations. Otherwise, I'm forced to move the terminal a bit for it to refresh UI as shown in the videos below (I have used Ubuntu Terminal since it has no flickering):
screen-capture-without-queue-update-draw.webm
screen-capture-with-queue-update-draw.webm
And here's the project on Windows:
windows-flickering.webm
I have no problem running my application in Ubuntu, but I really wanted it to work in Windows as well since that's where it's being used the most.
Kindly have a look and advise.
@rivo commented on GitHub (Nov 4, 2023):
It is necessary to clear the screen before each call to
Draw()(see https://github.com/rivo/tview/issues/899#issuecomment-1777112223). This should generally not be a problem. But in your particular example, you are creating an endless loop of calls toDraw(): In yourSetAfterDrawFunc()callback, you're scheduling anotherDraw()invocation. And then again and again.I'm not sure why you are doing that, but even if there was no flickering, it would keep the CPU unnecessarily busy. I'm guessing that there is a slight difference in terminals on Windows and on other OSes but it happens on non-Windows OSes too, it's just not visible.
Maybe you want to clarify why you create an endless
Draw()cycle?@Vinrithi commented on GitHub (Nov 4, 2023):
Thanks for the clarification on what is happening. I've relooked at my code and I've seen I might have been messing up by calling
I had some windows like alerts and progress bars made using the winman library, and was having difficulties showing and hiding them, until I encountered the function above. It was solving the issues I had, but didn't know the repercussions in things like CPU usage. I've reimplemented using Draw() and the program is running well on both Windows and Linux with minimal CPU usage.