ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
6.73k stars 401 forks source link

Cursor randomly appears on screen #602

Closed v1nns closed 1 year ago

v1nns commented 1 year ago

Hi @ArthurSonzogni,

It has been some time since I've updated the FTXUI GIT_TAG on CMake that I'm using as dependency on my project. And I saw that after this commit "Support multiple kind of cursor shapes. (#505)" (SHA1 1689802349c241c4f51c272fe3ee3032342257ab), something strange is happening.

Every time that I send custom event to redraw UI, a cursor randomly appears on the screen (I'm currently using kitty as terminal, but I didn't test with other terminals). Check video below:

https://user-images.githubusercontent.com/22479290/227597188-f36d8217-806a-48db-ac50-878c1876ad3d.mov

I'd like to ask if you know something about this or how to fix it.

ArthurSonzogni commented 1 year ago

Wow! Nice UI. Would you have a link to your repository, so that I can reproduce? I am also using kitty

ArthurSonzogni commented 1 year ago

Wow! Nice UI. Would you have a link to your repository, so that I can reproduce? I am also using kitty

v1nns commented 1 year ago

Hahah, thanks! :heart_eyes:

Yes, but it is not finished yet: https://github.com/v1nns/spectrum/ I've still got some things to do before publishing it...

But I think you will have problem to build it because of some dependencies, just let me fix the Dockerfile first.

v1nns commented 1 year ago

Instead of fixing Dockerfile (that is not able to run because of ALSA), I'll take a little longer and modify the CMake file to enable this project to build without external dependencies. Otherwise, you would have to install additional packages in your system (ALSA, ffmpeg and fftw). So please, hold on until further notice.

v1nns commented 1 year ago

Hey @ArthurSonzogni,

I added the compile flag option, now it is possible to build the project without external dependencies for UI troubleshooting:

cd build; cmake -D SPECTRUM_DEBUG=ON ..
./src/spectrum -l /tmp/log.txt

With that, you will be able to see the default UI. And if you simply navigate on "Files" block, those random cursors will appear on screen.

ArthurSonzogni commented 1 year ago

Thanks!

I am able to compile with the option, but it doesn't reproduce the rendering issue. Maybe this is about the option. Can you reproduce with the option on your side?

v1nns commented 1 year ago

Hmm, that's strange, I've compiled with the DEBUG option, and got the same behaviour.

But this only happens when the application execute a lot of events to render again (for example, keep down any navigation key in the Files block). Check below:

https://user-images.githubusercontent.com/22479290/227808424-300f4fa1-7dae-47e6-9ca1-9592a6f87eaf.mov

TheAwesomeGem commented 1 year ago

This happens to me in every example code on Windows 10.

LostInCompilation commented 1 year ago

Cannot reproduce on macOS 13.3 with HyperTerminal. Everything works fine using the GUI only debug build. @v1nns You're using some deprecated unicode converters which gave me deprecation errors on clang:

'codecvt_utf8_utf16<wchar_t, 1114111, 0>' is deprecated
    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
v1nns commented 1 year ago

@LostInCompilation Did you change FTXUI GIT_TAG to a newer SHA1 inside src/CMakeLists.txt?

You got this error because right now spectrum is using an old commit from FTXUI (and in that point, it was using this deprecated method).

LostInCompilation commented 1 year ago

No I didn't change anything, just commented out the include gtest header and build with -DSPECTRUM_DEBUG=ON. I didn't check where the error was triggered, clang just said in libcpp string.h. Possible it's from an old FTXUI build. Should I test with the newest hash?

LostInCompilation commented 1 year ago

I built using 1689802349c241c4f51c272fe3ee3032342257ab, still cannot reproduce.

v1nns commented 1 year ago

Hmmm, good to know, I've changed my terminal font to test and got the same behavior.

Still following the idea of being related to terminal, I did some investigation on my terminal settings and discovered the problem: I was using "input_delay 0" in kitty settings, and after I removed it, that strange behavior is gone.

But now something else is happening: a single blinking cursor appears (at the bottom-right side of the screen) when I start playing some music. I'll record a video and attach here later.

v1nns commented 1 year ago

This is the blinking cursor (at the bottom-right, inside player block) I said in the previous comment:

https://user-images.githubusercontent.com/22479290/229368871-cc381690-e9dd-4d50-ab4b-59ecc691d0d0.mov

I added the cursor configuration for screen in main.cc,:

// Create a full-size screen, hide cursor and register callbacks
ftxui::ScreenInteractive screen = ftxui::ScreenInteractive::Fullscreen();
screen.SetCursor(ftxui::Screen::Cursor{.shape = ftxui::Screen::Cursor::Shape::Hidden});

It looks like it's being overwritten when I start playing a new song, but I don't change cursor settings anywhere else in the code.

ArthurSonzogni commented 1 year ago

I was able to make spectrum to run. After: https://github.com/v1nns/spectrum/pull/22

I tried the following terminal:

With all of them, I wasn't able to see any cursor glitches.

The code in FTXUI updating the cursor shape is: https://github.com/ArthurSonzogni/FTXUI/blob/master/src/ftxui/component/screen_interactive.cpp#L745-L762 You might be able to find out how to fix it.

v1nns commented 1 year ago

When I was about to debug using the latest commit from FTXUI (1397c10), that blinking cursor is no longer appearing in the screen.

Thank you for your help!

ArthurSonzogni commented 1 year ago

Awesome! Thanks for checking!

VogelPapaFinn commented 11 months ago

Hi, I still have this issue but only on windows. But it happens only when I move the mouse. I could not figure out a solution and it happens always, even when I only render a text:

    ScreenInteractive screen_ = ScreenInteractive::Fullscreen();
    Component mainComponent_ = Container::Horizontal({});
    screen_.Loop(Renderer(mainComponent_, [&](){return text("Test");}));

Are there any new information how to fix this?