termux-packages
termux-packages copied to clipboard
[Bug]: ncurses nonblocking character reading is falling.
Problem description
Problem
I have created a program to measure the fps in my terminal inside of Termux using ncurses. I first used nodelay, but it crashed Termux, so I used timeout with 0mas argument, but there was the same problem. Finally, I tried using timeout with 1 as argument and it worked, also I added napms with a value of 1 to the first version of my program, and it worked. I gussed that the issue was with my program or ncurses, so I searched information about it, and I don't found anything. Then, I tested inside Debian in proot-distro and the first version of my program worked perfectly! Because that, I'm reporting this as bug in Termux.
Program's code
#include <ncurses.h>
#include <sys/time.h>
int main()
{
struct timeval lastFrame, currentTime;
double elapsedTime = 0;
int input = 0;
long double framerate = 0;
initscr();
noecho();
curs_set(0);
nodelay(stdscr,TRUE);
cbreak();
gettimeofday(&lastFrame, NULL);
do
{
// Necesary in Termux.
// napms(1);
clear();
gettimeofday(¤tTime, NULL);
elapsedTime = (currentTime.tv_sec - lastFrame.tv_sec) + (currentTime.tv_usec - lastFrame.tv_usec) / 1000000.0;
framerate = 1.0 / elapsedTime;
printw("FPS: %08.2Lf", framerate);
refresh();
lastFrame = currentTime;
input = getch();
} while (input != 'q');
endwin();
}
Compilaton
-
Termux
- clang framerate.c -lncurses -o framerate
-
Debian (proot-distro)
- gcc framerate.c -lncurses -o framerate
What steps will reproduce the bug?
Run the binary produced by clang in termux.
What is the expected behavior?
See the current FPS.
System information
Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=2839
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://md.mirrors.hacktegic.com/termux/termux-main stable main
# x11-repo (sources.list.d/x11.list)
deb https://md.mirrors.hacktegic.com/termux/termux-x11 x11 main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
Updatable packages:
All packages up to date
termux-tools version:
1.38.3
Android version:
11
Kernel build information:
Linux localhost 4.14.186-22735277 #1 SMP PREEMPT Sat Feb 19 02:14:57 KST 2022 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-A225M
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.x11 versionCode:11
com.termux.styling versionCode:29