avnc icon indicating copy to clipboard operation
avnc copied to clipboard

Input works, display frozen

Open babaric-dev opened this issue 2 years ago • 26 comments

I do some multitasking on my phone. It got 8GB of RAM, a fairly new chip and it runs smoothly. However, in AVNC, after I leave the app and visit a few minutes later, the display freezes while mouse clicks and keyboard input works. May be related to #92 except it occurs even when RAM usage is around 50%.

babaric-dev avatar Dec 02 '22 08:12 babaric-dev

Yeah, it could be the same issue as in #92. Are you using termux too? Does it happen randomly or every time?

gujjwal00 avatar Dec 02 '22 09:12 gujjwal00

I use Termux. But it doesn't work if I am connecting to a Linux computer either.

Btw, it happens everytime after I leave AVNC in the background for a few minutes.

babaric-dev avatar Dec 02 '22 10:12 babaric-dev

Can you tell me a bit more about your setup?

  • Host OS name & version
  • VNC server name & version
  • Android version
  • Anything special about your setup (e.g. SSH)

If I can reproduce it locally, that would be really helpful.


the display freezes while mouse clicks and keyboard input works

Does the pointer/arrow moves when you click around, or is it frozen too?

gujjwal00 avatar Dec 02 '22 10:12 gujjwal00

Host: Ubuntu 22.04.1 LTS (Termux) VNC server: tigervnc-standalone-server (1.12.0+dfsg-4) Guest: Android 13, Samsung (One UI 5)

Special setup: PhantomProcessKiller is disabled with

settings put global settings_enable_monitor_phantom_procs false

Does the pointer/arrow moves when you click around, or is it frozen too?

I don't really understand the question. Anyway, the cursor on screen moved around and the mouse input to the vnc also respects the local cusor position. In short, it is just the display frozen.

Again, same as #92, this never happened in VNC Viewer by RealVNC Limited. I use AVNC simply it looks nicer and is open-source. :)

Do not hesitate to ask if there are more questions :)

babaric-dev avatar Dec 02 '22 11:12 babaric-dev

I don't really understand the question. Anyway, the cursor on screen moved around and the mouse input to the vnc also respects the local cusor position. In short, it is just the display frozen.

I was trying to rule out any graphics related issue. AVNC uses OpenGL ES to render the framebuffer received from server. It also draws the pointer icon, mostly an arrow, on current pointer position. When you tap on the screen, trying to send a click to remote server, AVNC will update the pointer position to where you tapped, and will redraw the icon on new position.

When display is frozen, if tapping on screen moves the pointer without updating rest of the stuff, than it means that rendering is working correctly, just the framebuffer is not being updated.

gujjwal00 avatar Dec 02 '22 12:12 gujjwal00

Btw, this bug I am facing isn't related to the Android 13 update. It occurs on Android 10 and 12 as well. So, it pretty much isn't a problem about the Android version.

babaric-dev avatar Dec 02 '22 23:12 babaric-dev

Thanks. Can you check if atleast pointer is still movable as I explained above?

gujjwal00 avatar Dec 03 '22 01:12 gujjwal00

I think a visualization of the issue would help. That's why I screen recorded a session with touches shown:

https://user-images.githubusercontent.com/104625126/205436294-b1c17b6d-8ad1-4d64-a497-1eb1a2e296a9.mp4

https://user-images.githubusercontent.com/104625126/205436297-9ff1f755-4d06-418a-9cc8-e2976c63eed6.mp4

before.mp4: Before leaving AVNC in background after.mp4: Entering AVNC after a few minutes

Hope this helps so AVNC will get better and better.

babaric-dev avatar Dec 03 '22 10:12 babaric-dev

Thanks, that's really helpful.

gujjwal00 avatar Dec 03 '22 11:12 gujjwal00

Confirming I got this problem sometime.

tuanpham-dev avatar Dec 03 '22 14:12 tuanpham-dev

I will try to reproduce this locally by setting up Termux on my Android 12 device.

@tuanpham-dev using https://github.com/tuanpham-dev/termux-ubuntu should be enough to get started, right?

gujjwal00 avatar Dec 03 '22 14:12 gujjwal00

@gujjwal00 - Yes, it should. You also need to disable PhantomProcessKiller to prevent the[Process completed (signal 9) - press Enter] problem.

tuanpham-dev avatar Dec 03 '22 14:12 tuanpham-dev

@gujjwal00 I use proot-distro with XFCE on Ubuntu 22.04.1. Andronix, termux-ubuntu and similar projects should work too.

babaric-dev avatar Dec 03 '22 15:12 babaric-dev

disable PhantomProcessKiller to prevent the[Process completed (signal 9) - press Enter]

@gujjwal00 Run

/system/bin/device_config put activity_manager max_phantom_processes 2147483647

using ADB. This takes effect until next reboot.

babaric-dev avatar Dec 03 '22 15:12 babaric-dev

@babaric-dev Yeah, I saw that option when skimming through Termux repo and issues related to Android 12.

gujjwal00 avatar Dec 03 '22 15:12 gujjwal00

Is anyone except me able to reproduce the issue?

babaric-dev avatar Dec 04 '22 09:12 babaric-dev

I was able to setup Ubuntu with Termux, and I can reproduce it successfully.

Can you try disabling any battery optimizations for AVNC?

gujjwal00 avatar Dec 04 '22 09:12 gujjwal00

I think it works!!! But disabling battery optimizations would drain battery(?)

babaric-dev avatar Dec 04 '22 10:12 babaric-dev

Btw, how does VNC Viewer by RealVNC Limited work without disabling battery optimizations? (may be hard to answer since it isn't open source)

babaric-dev avatar Dec 04 '22 10:12 babaric-dev

So here is what I have found so far: When AVNC goes in background, battery optimizer seems to kick-in after 3-4 minutes and suspend AVNC threads. Meanwhile, the server keeps running in Termux. This seems to create some sort of synchronization issue, possibly a timeout, and framebuffer updates seems to stop coming from server. You may notice that the clock on frozen display is stuck far behind the real time.

I haven't yet figured out why only tigervnc shows this behavior.

I think it works!!! But disabling battery optimizations would drain battery(?)

Normally, yes! But in this specific case you are unlikely to notice any difference:

  • Connection is local, so no radios (e.g. WiFi) are involved. Bytes are simply shuffling around in RAM.
  • Xfce is a simple DE, so relatively few updates are happening.
  • You can enable Raw image quality in advanced server options to avoid CPU used by compression/decompression.

Btw, how does VNC Viewer by RealVNC Limited work without disabling battery optimizations? (may be hard to answer since it isn't open source)

Does it show a sticky notification in Android status bar during connection? That may explain why it is not suspended.

gujjwal00 avatar Dec 04 '22 10:12 gujjwal00

Just downloaded VNC Viewer to test it. Apparently, it actually reconnects after being in background for a few minutes.

Steps:

  1. Download VNC Viewer and install it from Google Play Store
  2. Connect to a server
  3. Enter password but do NOT tick the remember password box
  4. Leave app running in the background for a few minutes
  5. Re-enter the app

It asks for your password.

Btw, I am not able to enable notifications for the app (I am on Android 13 and notifications are disabled by default). So I cannot answer your question about the notification.

babaric-dev avatar Dec 04 '22 12:12 babaric-dev

Just downloaded VNC Viewer to test it. Apparently, it actually reconnects after being in background for a few minutes.

AVNC also does this, but only when app's process is killed by Android to reclaim memory. When user switches back to AVNC, it will reconnect to the server. Here, app seems to suspended instead of being killed.

Btw, I am not able to enable notifications for the app (I am on Android 13 and notifications are disabled by default). So I cannot answer your question about the notification.

No problem, thanks for testing VNC Viewer.


So there are two possible workarounds I can think of:

  1. Run a foreground service: This is similar to how music/video apps behave. Termux also uses this approach. This will show a sticky notification in notification panel. AVNC will keep running in background, unaffected by any battery optimizations. The drawback is that AVNC may consume more battery or network bandwidth. It also seems a bit complex to implement.
  2. Reconnect if App is suspended in background: AVNC could try to detect if it was suspended while in background, and reconnect if required. While this plays nicely with battery, I have to test if the detection will actually work. It also seems slightly brittle.

gujjwal00 avatar Dec 07 '22 17:12 gujjwal00

  1. Warn the user about battery optimization if not disabled

babaric-dev avatar Dec 07 '22 22:12 babaric-dev

Is anyone except me able to reproduce the issue?

I usually tab back to termux and the problem is solved

xDoge26 avatar Mar 28 '23 10:03 xDoge26

I've also had this/#92 happen to me a couple of times now. I've only noticed it when connecting to TigerVNC under Termux on the same device, not when connecting to my Mac[^spaces], but that's probably because I'm more likely to switch out of AVNC in that case (looking things up, switching back to Termux to install packages, etc.).

The last time it happened, I was able to shut down the VNC/X11 server using a keyboard shortcut, but AVNC didn't notice the server going away and switch to the 'Disconnected' screen, even though vncserver -list confirmed it was no longer running.

[^spaces]: Actually, I have had it get in a similar state with the Mac, but I suspect it's a different issue: that happens when I switch Spaces(/desktops/whatever they're called now) on the Mac, and seems to have nothing to do with what's happening on the tablet.

Rhys-T avatar Apr 20 '23 19:04 Rhys-T

Hi all, I have been implementing several fixes/workarounds to resolve this issue:

  1. Display getting frozen during Cut/Copy operations (#92) should be fixed already. It was caused by a bug in LibVNCClient.
  2. Now when you switch back to AVNC after some time, it tries to refresh the screen from server, and will auto-reconnect if there is an issue. This should work similar to RealVNC, as mentioned by @babaric-dev above.
  3. If you are still facing the issue, please update to the v2.5.2 and enable Settings => Viewer => Pause updates when in background option. AVNC will stop asking for screen updates when in background, which should avoid the synchronization issue.

With the 3rd option, you don't need to disable battery optimizations for AVNC. I am hoping to finally fix this for good.

gujjwal00 avatar Jul 20 '24 16:07 gujjwal00