Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input works, display frozen #105

Open
babaric-dev opened this issue Dec 2, 2022 · 26 comments
Open

Input works, display frozen #105

babaric-dev opened this issue Dec 2, 2022 · 26 comments

Comments

@babaric-dev
Copy link
Contributor

babaric-dev commented Dec 2, 2022

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 babaric-dev changed the title Input worka, display frozen Input works, display frozen Dec 2, 2022
@gujjwal00
Copy link
Owner

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

@babaric-dev
Copy link
Contributor Author

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.

@gujjwal00
Copy link
Owner

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?

@babaric-dev
Copy link
Contributor Author

babaric-dev commented Dec 2, 2022

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 :)

@gujjwal00
Copy link
Owner

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.

@babaric-dev
Copy link
Contributor Author

babaric-dev commented Dec 2, 2022

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.

@gujjwal00
Copy link
Owner

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

@babaric-dev
Copy link
Contributor Author

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

before.mp4
after.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.

@gujjwal00
Copy link
Owner

Thanks, that's really helpful.

@tuanpham-dev
Copy link
Contributor

Confirming I got this problem sometime.

@gujjwal00
Copy link
Owner

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?

@tuanpham-dev
Copy link
Contributor

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

@babaric-dev
Copy link
Contributor Author

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

@babaric-dev
Copy link
Contributor Author

babaric-dev commented Dec 3, 2022

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.

@gujjwal00
Copy link
Owner

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

@babaric-dev
Copy link
Contributor Author

Is anyone except me able to reproduce the issue?

@gujjwal00
Copy link
Owner

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

Can you try disabling any battery optimizations for AVNC?

@babaric-dev
Copy link
Contributor Author

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

@babaric-dev
Copy link
Contributor Author

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

@gujjwal00
Copy link
Owner

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.

@babaric-dev
Copy link
Contributor Author

babaric-dev commented Dec 4, 2022

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.

@gujjwal00
Copy link
Owner

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.

@babaric-dev
Copy link
Contributor Author

  1. Warn the user about battery optimization if not disabled

@xDoge26
Copy link

xDoge26 commented Mar 28, 2023

Is anyone except me able to reproduce the issue?

I usually tab back to termux and the problem is solved

@Rhys-T
Copy link

Rhys-T commented Apr 20, 2023

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 Mac1, 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.

Footnotes

  1. 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.

@gujjwal00
Copy link
Owner

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

  1. Display getting frozen during Cut/Copy operations (Display frozen, mouse and keyboard input still works #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants