droidVncServer icon indicating copy to clipboard operation
droidVncServer copied to clipboard

droidVNCserver compiled for armeabi architecture

Open hoehermann opened this issue 7 years ago • 7 comments

Ever since Android 5.0, Android enforces PIC (position independent code). As a result, the binary supplied in @f95fa6b will not start, resulting in #98 #104 #107 #119 . After the partial success described in #117, I want to share my experience, too. I did not compile the Java (GUI frontend) part of droidVncServer, I concentrated on the VNC server exclusively.

I have a Samsung Galaxy Nexus "Maguro" phone running CyanogenMod 13.0, which is Android 6.0.1 "Marshmallow".

Here is what I did:

  1. Based on this article by Nick Desaulniers, I installed the current linux version "r14" of the Android NDK for compiling native applications. I set my PATH to temporarily include the supplied cross compilers and ndk-build.

  2. droidVNCserver is relies on a VNC server implementation included in the module vnc. vnc itself shall be statically linked against three libraries jpeg libpng openssl. Additionally. vnc uses two dynamically loaded libraries flinger gralloc.
    I compiled vnc and its libraries with APP_ALLOW_MISSING_DEPS=true ndk-build. I needed APP_ALLOW_MISSING_DEPS=true since ndk-build complained about zlib being missing (although it is allegedly included in the Android system). The jpeg module fails for any architecture other than armeabi (same in #91 and #106; #118 mentions a possible workaround; failing to build libjpeg results in linking errors as described in #121). For this reason, I set APP_ABI:=armeabi in Application.mk.
    I did not manage to compile the two dynamically loaded libraries flinger gralloc. viren-nadkarni/droid-vnc-server@8bd5fcb states, you need the Android Open Source Project (AOSP) code. 160GB disk space and 16GB RAM looks a bit steep for a simple compilation. For now, I just use the precompiled ones included in the nativeMethods directory. I suppose, this causes the problems described below.

  3. I pushed the androidvncserver binary on my device and ran it:

    $ adb push libs/armeabi/androidvncserver /data/local/tmp/androidvncserver
    $ adb shell /data/local/tmp/androidvncserver
    Initializing grabber method...
    No grabber method selected, auto-detecting...
    --Loading flinger native lib--
    Loading lib: /data/data/org.onaips.vnc/lib//libdvnc_flinger_sdk10.so
    Couldnt load flinger library /data/data/org.onaips.vnc/lib//libdvnc_flinger_sdk10.so! Error string: (null)
    Loading lib: /data/data/org.onaips.vnc/lib//libdvnc_flinger_sdk14.so
    Couldnt load flinger library /data/data/org.onaips.vnc/lib//libdvnc_flinger_sdk14.so! Error string: (null)
    --Loading gralloc native lib--
    Loading lib: /data/data/org.onaips.vnc/lib//libdvnc_gralloc_sdk10.so
    WARNING: linker: /data/data/org.onaips.vnc/lib/libdvnc_gralloc_sdk10.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
    --Initializing gralloc access method--
    WARNING: linker: /system/vendor/lib/hw/gralloc.omap4460.so: unused DT entry: type 0xf arg 0x53b
    WARNING: linker: /system/vendor/lib/libsrv_um_SGX540_120.so: unused DT entry: type 0xf arg 0xeb9
    WARNING: linker: /system/vendor/lib/libpvr2d_SGX540_120.so: unused DT entry: type 0xf arg 0x767
    Gralloc method not supported by this device!
    Loading lib: /data/data/org.onaips.vnc/lib//libdvnc_gralloc_sdk14.so
    Couldnt load library /data/data/org.onaips.vnc/lib//libdvnc_gralloc_sdk14.so! Error string: (null)
    --Initializing framebuffer access method--
    line_lenght=2944 xres=720, yres=1280, xresv=720, yresv=1280, xoffs=0, yoffs=0, bpp=32
    Using Droid workaround
    Initializing virtual keyboard and touch device...
    ---Initializing uinput...---
    Initializing VNC server:
    width:  720
    height: 1280
    bpp:    32
    port:   5901
    Colourmap_rgba=16:8:0:24    lenght=8:8:8:8
    04/03/2017 09:20:51 Listening for VNC connections on TCP port 5901
    04/03/2017 09:20:51 Listening for HTTP connections on TCP port 5801
    04/03/2017 09:20:51   URL http://localhost:5801
    Starting IPC connection...binded to port 13132
    
    Waiting for a connection
    04/03/2017 09:20:58 Got connection from client
    04/03/2017 09:20:58   other clients:
    04/03/2017 09:20:58 Normal socket connection
    04/03/2017 09:20:58 Client Protocol Version 3.8
    04/03/2017 09:20:58 Protocol version sent 3.8, using 3.8
    04/03/2017 09:20:58 rfbProcessClientSecurityType: executing handler for type 1
    04/03/2017 09:20:58 rfbProcessClientSecurityType: returning securityResult for client rfb version >= 3.8
    04/03/2017 09:20:58 Pixel format for client:
    04/03/2017 09:20:58   32 bpp, depth 24, little endian
    04/03/2017 09:20:58   true colour: max r 255 g 255 b 255, shift r 16 g 8 b 0
    04/03/2017 09:20:58 Enabling full-color cursor updates for client
    04/03/2017 09:20:58 Enabling NewFBSize protocol extension for client
    04/03/2017 09:20:58 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFECC)
    04/03/2017 09:20:58 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFECD)
    04/03/2017 09:20:58 Enabling LastRect protocol extension for client
    04/03/2017 09:20:58 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC7)
    04/03/2017 09:20:58 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC8)
    04/03/2017 09:20:58 Using image quality level 8 for client
    04/03/2017 09:20:58 Using JPEG subsampling 0, Q92 for client
    04/03/2017 09:20:58 Using raw encoding for client
    04/03/2017 09:21:46 Client gone
    04/03/2017 09:21:46 Statistics            events    Transmit/ RawEquiv ( saved)
    04/03/2017 09:21:46  FramebufferUpdate   :      1 |        0/       0 (  0.0%)
    04/03/2017 09:21:46  raw               :      1 |   3686412/  3686412 (  0.0%)
    04/03/2017 09:21:46  RichCursor         :      1 |       255/      255 (  0.0%)
    04/03/2017 09:21:46  TOTALS             :      3 |   3686667/  3686667 (  0.0%)
    04/03/2017 09:21:46 Statistics            events    Received/ RawEquiv ( saved)
    04/03/2017 09:21:46  ClientCutText       :      2 |       50/       50 (  0.0%)
    04/03/2017 09:21:46  KeyEvent           :      2 |       16/       16 (  0.0%)
    04/03/2017 09:21:46  FramebufferUpdate   :      2 |       20/       20 (  0.0%)
    04/03/2017 09:21:46  SetEncodings       :      1 |       60/       60 (  0.0%)
    04/03/2017 09:21:46  SetPixelFormat      :      1 |       20/       20 (  0.0%)
    04/03/2017 09:21:46  PointerEvent       :     36 |       216/      216 (  0.0%)
    04/03/2017 09:21:46  TOTALS             :     44 |       382/      382 (  0.0%)
    
  4. I connected with TigerVNC 1.7.0 and... was disappointed. There is a couple of issues:

    • The screen view is a horrible mess. Screenshot
      In #76 the same problem is described without solution. Maybe this is what happens in #109, too, but that guy did not supply screenshots.
    • The pointer location is messed up. There is a horrible offset, but the movement direction is correct, unlike #125. Turning the phone does not help.
    • The screen view often becomes black (as described in #93 and #102). Having the phone's screen turned off, helps though.

These problems considered, I suspect the VNC server assumes incorrect framebuffer dimensions (width and height). With that, any mouse pointer position conversions are amiss. Reading from the framebuffer at invalid positions may result in the garbled or a black screen. I suspect, using a recent build of flinger and gralloc could help.

For those desperate ones, who want to experiment with this build, I uploaded the binary to my server. viren-nadkarni/droid-vnc-server@8bd5fcb provides binaries of flinger and gralloc, but using them androidvncserver terminates upon client connect.

hoehermann avatar Mar 04 '17 09:03 hoehermann

Can you explain how can I compile it with libvncserver 0.9.11 but for an Android device 6.01 x86_64? Best regards, Pedro Elisio

pedroelisio avatar Mar 24 '17 10:03 pedroelisio

I did not try myself. You probably need to edit Application.mk and make changes so it reads APP_ABI:=x86_64 and then simply invoke ndk-build. However, the source code for the JPEG library in oNaiPs fork seems to compile for architecture armeabi only. Please confer to the aforementioned issues and/or try another fork.

hoehermann avatar Mar 27 '17 10:03 hoehermann

I can't find an library that is compatible with X86 and X86/64. Can you point a fork that explicits the compatibility for the @least X86_64? Best Regards, Pedro Elisio

pedroelisio avatar Mar 27 '17 20:03 pedroelisio

You may try https://github.com/oNaiPs/droidVncServer/issues/118#issuecomment-233107171 . Apart from that, I do not have any further information about this particular issue. I am sorry.

hoehermann avatar Mar 28 '17 08:03 hoehermann

@hoehermann Hi, can you write an explanation for setup environment. And instructions for compile this project. It's my first time compiling a Android app. Best regards.

alexander-arce avatar May 10 '17 05:05 alexander-arce

I don't think that there are all libraries available. I was not able to compile it. Even DroidVNC app which is based on this github is not working in all phones. At least in my Asus Zenfone 3 is not working. Best regards, Pedro Elisio

pedroelisio avatar May 10 '17 07:05 pedroelisio

I somehow made it work fine in Android L (tested in a 5.1.1), but the mouse is inverted. Utilized the TightVNC client, some settings must had been done to optimize the speed.

Edit: Found the answer about the xy mouse inverted. In my case, is a ZTE device, so I started the app with -z parameter: /data/data/org.onaips.vnc/lib/libandroidvncserver.so -z

working fine :)

vrufino avatar Nov 21 '17 11:11 vrufino