termux-app
termux-app copied to clipboard
[Bug]: termux inconsistently crashes when resizing
Problem description
termux occasionally crashes when the screen is rotated, after failing to allocate a tiny amount memory, despite having multiple gigabytes free. crash appears to be related to number of terminal lines being improperly handled.
crash report: https://pastebin.pl/view/6332910e
Steps to reproduce the behavior.
I'm not fully sure how to reproduce the crash, but I believe it is related to terminal lines.
- produce a large number of data, creating many terminal lines.
- rotate screen
- crashes, complaining about not allocating a few hundred bytes; usually around 500 or so
What is the expected behavior?
terminal emulator viewport rotates, displaying terminal in widescreen mode.
System information
- Termux application version:
0.118.0+8569913
- Android OS version:
4.19.113-26203352
- Device model:
SM-N986U
Happened to me too. Specially happens when I set the terminal line numbers very high in termux.properties
.rotating screen doesn't really do it but when I go to zoom in/out in landscape mode termux crashes. I think when it displays a lot of texts.
@JaitinPrakash i will like to work on this issue but i need a bit more explanation
the terminal render pipeline can't seem to handle too many lines when changing the "screen properties" ie resizing the window or rotating the phone. i had previously set my maximum terminal lines to the largest possible number, but that would result in this crash very frequently. after changing that setting lower, it no longer happens. i believe it may be failing to properly acquire/utilize vram which would explain the ridiculously tiny amount memory it fails to allocate.
@JaitinPrakash It has nothing to do with video memory or vram you referred. Also the Java heap space available for allocation in Android app is much lower than free memory on your device.
Look carefully at the error message, especially the last part:
java.lang.OutOfMemoryError: Failed to allocate a 472 byte allocation with 2342584 free bytes and 2287KB until OOM, target footprint 268435456, growth limit 268435456; giving up on allocation because <1% of heap free after GC.
So the app indeed reached the maximum of the available heap space, possibly due to incorrect arrays handling which prevents Java garbage collector from freeing memory.
Crash happens at this line when creating a new TerminalRow object:
https://github.com/termux/termux-app/blob/6727bbecc4ddc92933fbc7426cf153d11c09a12f/terminal-emulator/src/main/java/com/termux/terminal/TerminalBuffer.java#L238