UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Running Wayland apps on edge?

    Scheduled Pinned Locked Moved App Development
    19 Posts 4 Posters 2.0k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • Z Offline
        zubozrout
        last edited by

        Hi,
        I've tried to compile an SDL demo with Wayland instead of Mir which should be a way to go now on edge (at least as far as I know) but the compiled app seems not to be able to start at all:

        terminate called after throwing an instance of 'SDL2pp::Exception'
          what():  SDL_Init failed: No available video device
        

        Except for the Mir/Wayland SDL part everything is the same as in this project: https://gitlab.com/zub2/SDLDemo

        Do I need to modify anything in the .desktop file for instance to get it running or is it more difficult than that?

        alan_gA dobeyD 2 Replies Last reply Reply Quote 0
        • alan_gA Offline
          alan_g @zubozrout
          last edited by

          I don't know the details of how edge is set up, but I do have experience of running Wayland apps on Mir servers. So there are a few questions:

          1. Is there a wayland-0 file in $XDG_RUNTIME_DIR and does your app have permissions to open it?
          2. Is $WAYLAND_DISPLAY set in your app environment? To something other than wayland-0?
          3. Does the click confinement prevent access to this file?
          4. Does Unity8 allow the connection?

          If you set WAYLAND_DEBUG=client before starting your app, the libwayland library will write what's happening (if anything) to the console log. There may be clues there.

          dobeyD Z 2 Replies Last reply Reply Quote 2
          • dobeyD Offline
            dobey @alan_g
            last edited by

            @alan_g said in Running Wayland apps on edge?:

            Does the click confinement prevent access to this file?

            Almost certainly, as apps can only access their package-specific path in $XDG_RUNTIME_DIR I think. We might need to add something to the apparmor policy to allow apps to see this socket?

            @alan_g said in Running Wayland apps on edge?:

            Does Unity8 allow the connection?

            If it's a valid APP_ID which it knows about, then yes, assuming it gets that far.

            alan_gA 1 Reply Last reply Reply Quote 0
            • dobeyD Offline
              dobey @zubozrout
              last edited by

              @zubozrout We are still using the mirclient API on edge, as there are still several things missing from Wayland which are required for certain aspects of the system to work (such as trust store, which handles location/camera permissions, and online-accounts which uses trusted overlays).

              Wayland has not really been tested there yet, so there will still likely be some problems for confined apps in this respect.

              1 Reply Last reply Reply Quote 2
              • alan_gA Offline
                alan_g @dobey
                last edited by

                @dobey said in Running Wayland apps on edge?:

                Almost certainly, as apps can only access their package-specific path in $XDG_RUNTIME_DIR I think. We might need to add something to the apparmor policy to allow apps to see this socket?

                That sounds similar to the situation with snaps. As well as the AppAmour policy, client apps need to do a "little dance" to use the Wayland socket. For example: https://github.com/MirServer/mir-kiosk-kodi/blob/master/glue/bin/kodi-launch.sh

                1 Reply Last reply Reply Quote 0
                • Z Offline
                  zubozrout @alan_g
                  last edited by

                  Thank you all for your reply :).

                  phablet@ubuntu-phablet:~$ echo $XDG_RUNTIME_DIR
                  /run/user/32011
                  phablet@ubuntu-phablet:~$ ls /run/user/32011/
                  confined      mir_socket          upstart-dbus-bridge.1685.pid
                  dbus-session  mir_socket_trusted  upstart-file-bridge.1685.pid
                  dconf         pulse               upstart-udev-bridge.1685.pid
                  keyring       signond             wayland-0
                  libertine     upstart             wayland-0.lock
                  

                  $WAYLAND_DISPLAY - I don't thinks it is set at all but maybe I am looking wrong.

                  I've also tried to make the app unconfined and there is no difference in the error at all.
                  https://www.iubuntu.cz/apps/zub.sdldemo_0.2_armhf.click (unconfined click with some binaries with it - I've built it from the zub's source, it is hosted on my server, but you should never trust random packages like that so this is only for those very adventurous)

                  alan_gA dobeyD 2 Replies Last reply Reply Quote 0
                  • alan_gA Offline
                    alan_g @zubozrout
                    last edited by

                    @zubozrout said in Running Wayland apps on edge?:

                    $WAYLAND_DISPLAY - I don't thinks it is set at all but maybe I am looking wrong.

                    That's fine - it overrides the default of wayland-0.

                    If you've dropped any confinement then the next question is:

                    What are the permissions on $XDG_RUNTIME_DIR/wayland-0?

                    Z 1 Reply Last reply Reply Quote 0
                    • Z Offline
                      zubozrout @alan_g
                      last edited by

                      @alan_g Seems ok to me:

                      phablet@ubuntu-phablet:~$ ls -al $XDG_RUNTIME_DIR/wayland-0
                      srwxrwxr-x 1 phablet phablet 0 srp 14 17:01 /run/user/32011/wayland
                      
                      alan_gA 1 Reply Last reply Reply Quote 0
                      • alan_gA Offline
                        alan_g @zubozrout
                        last edited by

                        If you set WAYLAND_DEBUG=client when starting your app, the libwayland library will write what's happening (if anything) to the console log. There may be clues there.

                        Z 1 Reply Last reply Reply Quote 0
                        • Z Offline
                          zubozrout @alan_g
                          last edited by zubozrout

                          I've tried this but it doesn't seem to be the way to go (It doesn't tell me more info):
                          WAYLAND_DEBUG=client ubuntu-app-launch zub.sdldemo_SDLDemo_0.2

                          And running just this doesn't tell me much more but I'd expect there would be something missing for the app to run without ubuntu-app-launch:

                          phablet@ubuntu-phablet:~$ WAYLAND_DEBUG=client /opt/click.ubuntu.com/zub.sdldemo/current/sdl_demo 
                          terminate called after throwing an instance of 'SDL2pp::Exception'
                            what():  SDL_Init failed: No available video device
                          Aborted
                          
                          1 Reply Last reply Reply Quote 0
                          • dobeyD Offline
                            dobey @zubozrout
                            last edited by

                            @zubozrout said in Running Wayland apps on edge?:

                            I've also tried to make the app unconfined and there is no difference in the error at all.

                            You did change the version number when doing this, yes? Or completely removed the old version first? Otherwise it will still have the old profile from the previous install.

                            Z 1 Reply Last reply Reply Quote 0
                            • Z Offline
                              zubozrout @dobey
                              last edited by

                              @dobey Ha, good point. I'll try that when I can - and thank you very much for the info :).

                              1 Reply Last reply Reply Quote 0
                              • Z Offline
                                zubozrout
                                last edited by

                                Ok, I am getting the same error even if I remove and install the app again or compile it with a higher version number.

                                alan_gA dobeyD 2 Replies Last reply Reply Quote 0
                                • alan_gA Offline
                                  alan_g @zubozrout
                                  last edited by

                                  Is SDL_VIDEODRIVER=wayland? Or mir?

                                  1 Reply Last reply Reply Quote 0
                                  • dobeyD Offline
                                    dobey @zubozrout
                                    last edited by

                                    @zubozrout Are your changes in a branch of git, which I could compile locally for x86?

                                    Z 1 Reply Last reply Reply Quote 0
                                    • Z Offline
                                      zubozrout @dobey
                                      last edited by

                                      @dobey This one should be it: https://gitlab.com/zubozrout/sdl2-demo/tree/wayland

                                      To build it it should hopefully be enough to follow these instructions: https://gitlab.com/zubozrout/sdl2-demo/tree/wayland#building-the-sdl2-demo-project

                                      1 Reply Last reply Reply Quote 1
                                      • mariogripM Offline
                                        mariogrip Administrators
                                        last edited by

                                        If this is an android device, wayland currently will not work on stock edge, as some changes to the android graphic plugin is needed for wayland to work.

                                        See: https://github.com/ubports/mir-android-platform/pull/7

                                        I have setup an experimental branch that you can try:

                                        sudo ubports-qa install xenial_-_edge_-_wayland
                                        

                                        but yeah, this is highly experimental 🙃

                                        Please note that the "startup screen might just be black, but unity8 should come up after some time"

                                        To start any applications you need to set:

                                        export EGL_PLATFORM=wayland
                                        
                                        Z 1 Reply Last reply Reply Quote 2
                                        • Z Offline
                                          zubozrout @mariogrip
                                          last edited by

                                          It seems like this is a bit more difficult on MX4 (no space left in the respective filesystem) - but with a bit of persuading I was able to get the update installed following these steps:

                                          1. sudo ubports-qa install xenial_-_edge_-_wayland (finished with error)
                                          2. apt -o Dir::Cache::Archives=/home/phablet/Downloads full-upgrade (processing the updates using Downloads folder to save the packages to prior installing)

                                          With the above modifications I can confirm the screen being black on startup :).
                                          Unfortunately though I am still getting what(): SDL_Init failed: No available video device. And this could be an issue with my Wayland modifications in the code - which now seems more probable.

                                          1 Reply Last reply Reply Quote 0
                                          • dobeyD Offline
                                            dobey
                                            last edited by

                                            If you build your app on a PC with your build of SDL, does it work under wayland/weston? That's probably a good place to start debugging.

                                            Once that's working, if you have a 16.04 VM set up with unity8 installed, I would build an x86 version of the click, install it in the VM, and see what works.

                                            Once both of those are working, it should also work on phones/tablets, once the remaining bits to get wayland clients working there are done.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post