meta-flutter / workspace-automation

Work aids for developing with Embedded Flutter on Linux
Apache License 2.0
6 stars 5 forks source link

error 0: agl_shell has already been bound #14

Closed malik727 closed 1 year ago

malik727 commented 1 year ago

I was trying to run flutter workspace automation to test a basic Flutter app I was developing for Automotive Grade Linux. I am facing a weird issue with no proper error information. My exact steps to reproduce the problem:

Installed the Flutter workspace automation. Initialized the environment "source ./setup_env.sh". Then type "run-agl-qemu-octopus". Also ensured all ssh settings are correct and working.

I copied my application folder to "app/" dir inside the flutter workspace main directory. Then by navigating to my application folder, I typed the following command: flutter run

Gives me the following error:

Connected devices:
Linux (desktop)                        • linux            • linux-x64 • Ubuntu
22.04.3 LTS 6.2.0-32-generic
AGL master-15.0.3 QEMU Image (mobile)  • agl-qemu-master  • linux-x64 •
qemu-master 15.0.3
AGL octopus-15.0.3 QEMU Image (mobile) • agl-qemu-octopus • linux-x64 •
qemu-octopus 15.0.3
[1]: Linux (linux)
[2]: AGL master-15.0.3 QEMU Image (agl-qemu-master)
[3]: AGL octopus-15.0.3 QEMU Image (agl-qemu-octopus)
Please choose one (or "q" to quit): 3
Launching lib/main.dart on AGL octopus-15.0.3 QEMU Image in debug mode...
[INFO:configuration.cc(248)] **********
[INFO:configuration.cc(249)] * Global *
[INFO:configuration.cc(250)] **********
[INFO:configuration.cc(251)] Application Id: .......... flutter-auto
[INFO:configuration.cc(253)] JSON Configuration: ...... /tmp/agl_flutter_voiceassistant/default_config.json
[INFO:configuration.cc(255)] Cursor Theme: ............ 
[INFO:configuration.cc(256)] Disable Cursor: .......... false
[INFO:configuration.cc(258)] Debug Backend: ........... false
[INFO:configuration.cc(260)] ********
[INFO:configuration.cc(261)] * View *
[INFO:configuration.cc(262)] ********
[INFO:configuration.cc(269)] Bundle Path: .............. /tmp/agl_flutter_voiceassistant
[INFO:configuration.cc(270)] Window Type: .............. BG
[INFO:configuration.cc(271)] Size: ..................... 1920 x 1080
[INFO:configuration.cc(273)] Fullscreen: ............... false
[INFO:configuration.cc(275)] Accessibility Features: ... 0
agl_shell@12: error 0: agl_shell has already been bound
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(553)] **** EGL Error
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(554)]     error: 12289
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(555)]     command: eglGetConfigs
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(594)]     error: 12289
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(597)]     messageType: 13242
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(598)]     threadLabel: (nil)
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(599)]     objectLabel: (nil)
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(600)]     message: eglGetConfigs
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(553)] **** EGL Error
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(554)]     error: 12289
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(555)]     command: eglChooseConfig
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(594)]     error: 12289
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(597)]     messageType: 13242
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(598)]     threadLabel: (nil)
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(599)]     objectLabel: (nil)
[ERROR:/usr/src/debug/flutter-auto-runtimerelease/git-r0/git/shell/backend/egl.cc(600)]     message: eglChooseConfig
Connection to localhost closed.

In the AGL terminal, I get the following output:

[   41.344111] show_signal_msg: 41 callbacks suppressed
[   41.344116] flutter-auto[494]: segfault at 0 ip 000055a2376c9294 sp 00007ffead734760 error 4 in flutter-auto[55a2376a6000+2e000]
[   41.345849] Code: ff 4c 8d 44 24 2c 4c 89 e2 89 e9 e8 36 a2 00 00 83 7c 24 2c 00 7e 3a 31 db 4c 8d 74 24 24 48 8b 2c 24 0f 1f 40 00 48 8b 7d 20 <49> 8b 34 dc ba 20 30 00 00 4c 89 f1 e8 1b a2 00 00 8b 45 18 3b 44
jwinarske commented 1 year ago

@malik727 What AGL branch and config are you working with?

malik727 commented 1 year ago

@jwinarske I am using AGL Octopus 15.0.3.

My config file looks something like this:

{
    "id": "agl-qemu-octopus",
    "load": true,
    "supported_archs": [
        "x86_64",
        "arm64"
    ],
    "supported_host_types": [
        "darwin",
        "ubuntu",
        "fedora"
    ],
    "flutter_runtime": "debug",
    "type": "qemu",
    "env": {
        "RELEASE_NAME": "octopus",
        "RELEASE_VERSION": "15.0.3",
        "FLUTTER_DEBUG_PORT": "1234",
        "FLUTTER_OBSERVATORY_HOST": "0.0.0.0",
        "CONTAINER_SSH_PORT": "2222",
        "DEVICE_HOSTNAME": "localhost",
        "FLUTTER_AUTO_EXE": "flutter-auto --j=/tmp/${appName}/default_config.json --b=/tmp/${appName}",
        "PING_CMD": "(echo >/dev/tcp/localhost/${CONTAINER_SSH_PORT}) &>/dev/null && echo open || echo closed",
        "DELETE_USER_PWD": "ssh -p ${CONTAINER_SSH_PORT} -t -oBatchMode=yes root@${DEVICE_HOSTNAME} passwd -d agl-driver",
        "CREATE_BUNDLE_FOLDER": "ssh -p ${CONTAINER_SSH_PORT} -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} mkdir -p /tmp/${appName}/data",
        "CREATE_ASSETS_FOLDER": "ssh -p ${CONTAINER_SSH_PORT} -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} mkdir -p /tmp/${appName}/data/flutter_assets",
        "COPY_PLATFORM_ID_TO_DEVICE": "scp -P ${CONTAINER_SSH_PORT} -r ${PLATFORM_ID_DIR}/default_config.json agl-driver@${DEVICE_HOSTNAME}:/tmp/${appName}/",
        "COPY_ASSETS_TO_DEVICE": "scp -P ${CONTAINER_SSH_PORT} -r ${localPath}/* agl-driver@${DEVICE_HOSTNAME}:/tmp/${appName}/data/flutter_assets",
        "DELETE_APP_FOLDER": "ssh -p ${CONTAINER_SSH_PORT} -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} rm -rf /tmp/${appName}"
    },
    "runtime": {
        "config": {
            "view": [
                {
                    "window_type": "BG",
                    "width": 1920,
                    "height": 1080
                }
            ]
        },
        "pre-requisites": {
            "arm64": {
                "darwin": {
                    "cmds": [
                        "bash -c \"arch -arm64 brew install xz\"",
                        "bash -c \"arch -arm64 brew install qemu\""
                    ]
                }
            }
        },
        "artifacts": {
            "http": {
                "url": "https://download.automotivelinux.org/AGL/release/${RELEASE_NAME}/${RELEASE_VERSION}",
                "artifacts": {
                    "x86_64": [
                        {
                            "endpoint": "/qemux86-64/deploy/images/qemux86-64/agl-ivi-demo-platform-flutter-qemux86-64.wic.vmdk.xz"
                        }
                    ],
                    "arm64": [
                        {
                            "endpoint": "/qemuarm64/deploy/images/qemuarm64/agl-demo-platform-crosssdk-qemuarm64.ext4.xz"
                        },
                        {
                            "endpoint": "/qemuarm64/deploy/images/qemuarm64/Image-qemuarm64.bin"
                        }
                    ]
                }
            }
        },
        "qemu": {
            "cmd": "qemu-system-${FORMAL_MACHINE_ARCH}",
            "x86_64": {
                "image": "agl-ivi-demo-platform-flutter-qemux86-64.wic.vmdk",
                "args": "-m 2048 ${QEMU_EXTRA} -hda ${QEMU_IMAGE} -cpu kvm64 -cpu qemu64,+ssse3,+sse4.1,+sse4.2,+popcnt -vga virtio -device virtio-rng-pci -serial mon:stdio -serial null -device intel-hda -device hda-duplex -device virtio-net-pci,netdev=net0,mac=${RANDOM_MAC} -netdev user,id=net0,hostfwd=tcp::${CONTAINER_SSH_PORT}-:22,hostfwd=tcp::${FLUTTER_DEBUG_PORT}-:${FLUTTER_DEBUG_PORT}"
            },
            "arm64": {
                "kernel": "Image-qemuarm64.bin",
                "image": "agl-demo-platform-crosssdk-qemuarm64.ext4",
                "args": "-accel hvf -cpu host -M virt ${QEMU_EXTRA} -m 4096 -device virtio-gpu-pci -nographic -display cocoa,show-cursor=on -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -device qemu-xhci -device usb-tablet -device usb-mouse -device usb-kbd -device virtio-net-pci,netdev=vnet -netdev user,id=vnet,hostfwd=tcp::${CONTAINER_SSH_PORT}-:22,hostfwd=tcp::${FLUTTER_DEBUG_PORT}-:${FLUTTER_DEBUG_PORT} -kernel ${QEMU_KERNEL} -drive file=${QEMU_IMAGE},format=raw,if=virtio -append root=/dev/vda"
            },
            "extra": {
                "darwin": "-smp cpus=8,sockets=1,cores=8,threads=1",
                "ubuntu": "-bios OVMF.fd",
                "fedora": "-bios /usr/share/edk2/ovmf/OVMF_CODE.fd"
            }
        },
        "post_cmds": [
            {
                "cwd": "${PLATFORM_ID_DIR}",
                "cmds": [
                    "bash -c \"rm ${QEMU_IMAGE}|true\"",
                    "unxz --keep ${QEMU_IMAGE}.xz"
                ]
            }
        ]
    },
    "overwrite-existing": true,
    "custom-device": {
        "id": "agl-qemu-${RELEASE_NAME}",
        "label": "AGL ${RELEASE_NAME}-${RELEASE_VERSION} QEMU Image",
        "sdkNameAndVersion": "qemu-${RELEASE_NAME} ${RELEASE_VERSION}",
        "platform": "linux-x64",
        "enabled": true,
        "ping": "bash -c \"${PING_CMD}\"",
        "pingSuccessRegex": "open",
        "postBuild": "bash -c \"${DELETE_USER_PWD}\"",
        "install": "bash -c \"${CREATE_BUNDLE_FOLDER} && ${CREATE_ASSETS_FOLDER} && ${COPY_PLATFORM_ID_TO_DEVICE} && ${COPY_ASSETS_TO_DEVICE}\"",
        "uninstall": "bash -c \"${DELETE_APP_FOLDER}\"",
        "runDebug": "bash -c \"ssh -p ${CONTAINER_SSH_PORT} -t -t -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} ${FLUTTER_AUTO_EXE}\"",
        "forwardPort": null,
        "forwardPortSuccessRegex": null,
        "screenshot": null
    }
}

I did make some changes to the above file as the default configuration wasn't working for me. I was facing two issues with the default configuration:

  1. While trying to run my Flutter app I was getting the error "/tmp/${appName}/data/flutter_assets" No such directory exists. My assumption was that we needed this directory to be present before copying assets to the device. So that's why I introduced the "{CREATE_ASSETS_FOLDER}" key-value pair to resolve this issue, and it kind of worked as I wasn't seeing the error anymore.
  2. The second change I made was to the "{runDebug}" key. As you can see I kind of specified the port name. The reason for this was that I kept getting Host key verification failed. error without specifying the port. I assume maybe I messed up this step somehow. If yes then what should be done to avoid the Host key verification failed. error that occurs with the original "{runDebug}" value?

In case you wondering I did run the ssh -p 2222 root@localhost who command and I am manually able to SSH into agl-driver@localhost if I want to so I doubt its an issue with known_host configuration, or maybe it is.

P.S. Thanks for replying :), hope this issue gets figured out.

Also just for your reference, this is a part of my build log that seemed kinda weird when I ran the flutter_workspace.py script:

Engine Version: 45f6e009110df4f34ec2cf99f63cf73b71b7a420
Working Directory: /home/malik/Desktop/AGL-Dev/flutter-automation/.config/flutter_workspace/flutter-engine
*********************************
** Downloading Engine artifact **
*********************************
** Downloading linux-x64-embedder.zip via https://storage.googleapis.com/flutter_infra_release/flutter/45f6e009110df4f34ec2cf99f63cf73b71b7a420/linux-x64/linux-x64-embedder
**************************
** Download Status: 404 **
**************************
***********************************************
** Failed to download linux-x64-embedder.zip **
***********************************************
***********************************
** Engine artifact not available **
***********************************

It doesn't download this specific artifact, I hope so that this isn't the root cause if the error.

jwinarske commented 1 year ago

@malik727 You should not have to make any changes to the config on AGL Gerrit. See the steps on AGL Gerrit: https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL/meta-agl-devel.git;a=blob;f=meta-agl-flutter/README.md;h=ba017d15122503e51c546eb14a18c99595354302;hb=HEAD#l45

Also I'm not sure the image you are pulling has Flutter enabled by default. Jan-Simon can answer this. The configs in AGL Gerrit have Flutter enabled in images the last I tested.

AGL configs: https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL/meta-agl-devel.git;a=tree;f=meta-agl-flutter/tools/configs;h=4818878259f628b8480746ec99eedbe95a4d01a4;hb=HEAD

jwinarske commented 1 year ago

@malik727 what's the status on this? Can I close this issue, or is there something outstanding here?

malik727 commented 1 year ago

@jwinarske So I was able to bypass this issue after following the resources you linked. I am still somewhat facing problems with SSH connectivity but I believe thats an issue with my machine's SSH configuration. I'll look into it to see what can be done. As for this issue, you may close it because I am not facing this error anymore.

Thanks for the help, highly appreciate it.

jwinarske commented 1 year ago

np