redroid-doc icon indicating copy to clipboard operation
redroid-doc copied to clipboard

Forced to use Swiftshader and disable Angle on Redroid12+ will get device OFFLINE error!

Open titusbiao opened this issue 1 year ago • 5 comments

Hello,

As @zhouziyang mentioned in #748 , to downgrade swiftshader (external/swiftshader) and disable angle, I have tried the following.

1. Fork the entire redroid project at my own git, and modifed the vendor_redroid/gpu_config.sh file as:

gpu_setup_guest() {
    echo "use GPU guest mode"

    VENDOR_EGL_DIR=/vendor/lib64/egl
    SYSTEM_EGL_DIR=/system/lib64
    EGL_ANGLE=libEGL_angle.so
    EGL_SS=libEGL_swiftshader.so
    egl=swiftshader

    #if [ -f $VENDOR_EGL_DIR/$EGL_ANGLE ] || [ -f $SYSTEM_EGL_DIR/$EGL_ANGLE ]; then
    #    egl=angle
    #elif [ -f $VENDOR_EGL_DIR/$EGL_SS ] || [ -f $SYSTEM_EGL_DIR/$EGL_SS ]; then
    #    egl=swiftshader
    #else
    #    echo "ERROR no SW egl found!!!"
    #fi

    setprop ro.hardware.egl $egl
    setprop ro.hardware.gralloc redroid
    setprop ro.hardware.vulkan pastel
}

Yes, to force egl=swiftshader! No angle!

2. Then follow the entire Building Steps (just point the redroid patches to my own git), and build the arm64_only redroid 12 image with MindTheGapps. Then I get my own docker image titusbiao/redroid-mindthegapps-arm64:12.0.0-arm64_only-swiftshader.

3. It's now time to run the docker image, using a GoogleCloud T2A VM (arm64 only). Oooops!! After runing, I can successfully ADB connect to the device, but cannot Scrcpy to it (with the latest scrcpy 2.6.1).

C:\Users\Administrator\Downloads\scrcpy-win64-v2.6.1>scrcpy -s 34.31.196.219:5555 --audio-codec=flac
scrcpy 2.6.1 <https://github.com/Genymobile/scrcpy>
INFO: FLAC audio: audio buffer increased to 120 ms (use --audio-buffer to set a custom value)
INFO: ADB device found:
INFO:     --> (tcpip)  34.31.196.219:5555              device  redroid12_arm64_only
C:\Users\Administrator\Downloads\scrcpy-win64-v2.6.1\scrcp... file pushed, 0 skipped. 70.5 MB/s (71112 bytes in 0.001s)
[server] INFO: Device: [redroid] redroid redroid12_arm64_only (Android 12)
[server] ERROR: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
        at com.genymobile.scrcpy.wrappers.DisplayManager.getDisplayInfo(DisplayManager.java:89)
        at com.genymobile.scrcpy.device.Device.<init>(Device.java:77)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:145)
        at com.genymobile.scrcpy.Server.internalMain(Server.java:290)
        at com.genymobile.scrcpy.Server.main(Server.java:245)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
ERROR: Server connection failed

A few minutes later, when using adb devices command, and the device is OFFLINE!!

4. Then following the Troubleshooting instructions, I get this logs: redroid-debug.1mquD9gf.zip

So, is there any other thing I missed to do? Or just modify the gpu_config.sh is not enough?

titusbiao avatar Sep 14 '24 07:09 titusbiao

FYI: 09-14 07:25:02.035 8492 8492 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 8492 (surfaceflinger), pid 8492 (surfaceflinger)

Make sure the following drivers present.

vendor/lib64/egl/libEGL_swiftshader.so
vendor/lib64/egl/libGLESv1_CM_swiftshader.so
vendor/lib64/egl/libGLESv2_swiftshader.so

zhouziyang avatar Sep 14 '24 10:09 zhouziyang

FYI: 09-14 07:25:02.035 8492 8492 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 8492 (surfaceflinger), pid 8492 (surfaceflinger)

Make sure the following drivers present.

vendor/lib64/egl/libEGL_swiftshader.so
vendor/lib64/egl/libGLESv1_CM_swiftshader.so
vendor/lib64/egl/libGLESv2_swiftshader.so

Thanks for the information. The mentioned drivers libEGL_swiftshader.so, libGLESv1_CM_swiftshader.so, and libGLESv2_swiftshader.so, are not presented.

However, in the official Redroid 12 image, the above 3 drivers are not presented either!! In the folder vendor/lib64/egl, it only has libEGL_angle.so libEGL_mesa.so libGLESv1_CM_angle.so libGLESv1_CM_mesa.so libGLESv2_angle.so libGLESv2_mesa.so.

So any other ideas? @zhouziyang

titusbiao avatar Sep 19 '24 04:09 titusbiao

Since redroid 12, GLES / EGL is emulated via angle; and that's why only libxxx_angle libs present.

Did you ever bring back swiftshader from redroid 11? And add the following in redroid.mk:

PRODUCT_PACKAGES += \
    libEGL_swiftshader \
    libGLESv1_CM_swiftshader \
    libGLESv2_swiftshader \
    vulkan.pastel \

zhouziyang avatar Sep 20 '24 02:09 zhouziyang

Many many thanks!

After many tests, I've successfully run swiftshader on redroid 12, but failed in redroid 13.

Here are the steps:

  1. Fork the entire 9 repositories: redroid-doc, local_manifests, device_redroid, redroid_patches, vendor_redroid, device_redroid-prebuilts, chromium-webview-stub, redroid-omx and redroid-c2, to my github repositories.

  2. Go to my local_manifests repository, to the exact branch like 12.0.0, modify the redroid.xml file as below: line 3: <remote name="redroid" fetch="https://github.com/titusbiao/" revision="redroid-12.0.0" /> line 17: <project path="device/redroid" name="device_redroid" groups="redroid" remote="redroid" revision="redroid-12.0.0" />

  3. Go to my device_redroid repository, to the exact branch like redroid-12.0.0, modify the redroid.mk file as below: line 50-60:

# PRODUCT_PACKAGES += \
#    libEGL_angle \
#    libGLESv1_CM_angle \
#    libGLESv2_angle \
#    vulkan.pastel \

PRODUCT_PACKAGES += \
    libEGL_swiftshader \
    libGLESv1_CM_swiftshader \
    libGLESv2_swiftshader \
    vulkan.pastel \
  1. Go to my vendor_redroid repository, to the MASTER branch, modify the gpu_config.sh file as below: function gpu_setup_guest():
gpu_setup_guest() {
    echo "use GPU guest mode"

    VENDOR_EGL_DIR=/vendor/lib64/egl
    SYSTEM_EGL_DIR=/system/lib64
    EGL_ANGLE=libEGL_angle.so
    EGL_SS=libEGL_swiftshader.so
    egl=swiftshader

    # if [ -f $VENDOR_EGL_DIR/$EGL_ANGLE ] || [ -f $SYSTEM_EGL_DIR/$EGL_ANGLE ]; then
    #     egl=angle
    # elif [ -f $VENDOR_EGL_DIR/$EGL_SS ] || [ -f $SYSTEM_EGL_DIR/$EGL_SS ]; then
    #     egl=swiftshader
    # else
    #     echo "ERROR no SW egl found!!!"
    # fi

    setprop ro.hardware.egl $egl
    setprop ro.hardware.gralloc redroid
    setprop ro.hardware.vulkan pastel
}
  1. Go to my redroid-doc repository, to the MASTER branch, and modify the android-builder-docker section as below: Search for any "https://github.com/remote-android/" and replace to your name, like "https://github.com/titusbiao/".

  2. Then follow all the steps in your android-builder-docker section (GApps is optional), to build your own swiftshader redroid.

After successfully building, Redroid 12 is running well with swiftshader as the screenshot below: redroid12

However, for Redroid 13, following the steps similar to the above (just modify to 13.0.0), it comes out different. Although the building is successful, when using scrcpy to run in Windows, it will output errors:

F:\GUIScrcpy\scrcpy-win64-v2.7>scrcpy -s 34.70.216.140:5555 --audio-codec=flac
scrcpy 2.7 <https://github.com/Genymobile/scrcpy>
INFO: FLAC audio: audio buffer increased to 120 ms (use --audio-buffer to set a custom value)
INFO: ADB device found:
INFO:     --> (tcpip)  34.70.216.140:5555              device  redroid13_arm64_only
F:\GUIScrcpy\scrcpy-win64-v2.7\scrcpy-server: 1 file pushed, 0 skipped. 26.0 MB/s (71200 bytes in 0.003s)
[server] INFO: Device: [redroid] redroid redroid13_arm64_only (Android 13)
[server] ERROR: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
        at com.genymobile.scrcpy.wrappers.DisplayManager.getDisplayInfo(DisplayManager.java:89)
        at com.genymobile.scrcpy.device.Device.<init>(Device.java:77)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:145)
        at com.genymobile.scrcpy.Server.internalMain(Server.java:290)
        at com.genymobile.scrcpy.Server.main(Server.java:245)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
ERROR: Server connection failed

Let's go to the trouble shooting, we've got this logs: redroid13-debug.UKEW41WD.zip

So, any other ideas about the swiftshader building in Redroid 13? How to migrate the swiftshader from 11-12 to 13?@zhouziyang

titusbiao avatar Oct 24 '24 14:10 titusbiao

logs from rom your redroid13 container: Abort message: 'couldn't find an OpenGL ES implementation, make sure you set ro.hardware.egl or ro.board.platform'

Check whether those libs are built succeeded.

zhouziyang avatar Oct 29 '24 05:10 zhouziyang