Qt/QML on Ubuntu Core


#21

Before you go any further, did you test if your application works on top of Mir itself - before snapping it up??

To do this, on your Ubuntu desktop, install “miral-examples” and “qtubuntu-desktop”, and for testing purposes “qtbase5-examples”.

In one terminal, run miral-kiosk - you should see a black window pop up.
In a second terminal, run

QT_QPA_PLATFORM=ubuntumirclient  /usr/lib/x86_64-linux-gnu/qt5/examples/gui/analogclock/analogclock"

you should see an analogue clock appear inside the miral-kiosk. That verifies that Qt and Mir can work together.

Now, to test your internal Qt application, run it from command line, making sure to specify

QT_QPA_PLATFORM=ubuntumirclient

first. You application window should appear inside the miral-kiosk and be functional. If not, then you need to learn why not.


#22

If you write about sudo systemctl start snap.mir-kiosk.mir-kiosk.service
So I started it, as I wrote before I see a black screen and the mouse cursor.
Now I try to rebuild the snap package with qtubuntu-desktop in stage-package.


#23

No, I literally meant the command “miral-kiosk”, on your Ubuntu desktop.


#24

Similarly, I tried to start the application, this is the output of the information I received:
QT_QPA_PLATFORM=ubuntumirclient bsp095project.BSP095launcherCoreSimulation
Starting CORE …
This application failed to start because it could not find or load the Qt platform plugin “ubuntumirclient”.

Available platform plugins are: linuxfb (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), minimal (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), offscreen (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), xcb (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), linuxfb, minimal, offscreen, xcb.

Reinstalling the application may fix this problem.
/snap/bsp095project/x1/bin/start_CORE_simulation.sh: line 13:  2287 Aborted                 $SNAP/bin/./CORE -D "$HOME" -T "$HOME" -S "${1:-${RANDOM}}"

#25

With this for now, I’m looking for information how it’s all installed on KDE Neon and Ubuntu desktop.


#26

That error indicates the ubuntumirclient QPA plugin is missing. It is supplied in the “qtubuntu-desktop” package, as I’ve said above.


#27

I think there are some problems during the preparation of the snap. Because I added on your advice

parts:
    files:
        plugin: dump
        source: scripts
        after: [integration]

    integration:
        plugin: nil
        stage-packages:
            - qtubuntu-desktop
            - libc-bin

#28

I build a snap package with a qtubuntu-desktop on a clean Ubuntu 16.04.2.
On Ubuntu-core I get the same error again:

QT_QPA_PLATFORM=ubuntumirclient bsp095project.BSP095launcherCoreSimulation
Starting CORE ...
This application failed to start because it could not find or load the Qt platform plugin "ubuntumirclient".

Available platform plugins are: linuxfb (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), minimal (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), offscreen (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), xcb (from /snap/bsp095project/x1/QT/5.5/gcc_64/plugins/platforms), linuxfb, minimal, offscreen, xcb.

This is the version of the scripts with which I build snap package.


Maybe I missed something?


#29

So it does not work. But on your advice I added this package qtubuntu-desktop to the snapcraft.yaml.
Please look, maybe something else in scripts I did not write?


#30

I found an error with the problem of finding the module ubuntumirclient.
I added paths to search the module that goes in the Qt, but I removed the path for the modules that are going on in the system.


#31

@greyback @alan_g

Tell me please, how can I determine the cause of the error in the application at startup?

Starting GUI application ...
Loading module: 'libubuntu_application_api_desktop_mirclient.so.3.0.0'
query.exec() failed:  "no such table: patients Unable to execute statement"
SQL:  "SELECT name, surname, last_visit_date, patient_id FROM patients ORDER BY surname"
/snap/bsp095project/x1/bin/start_GUI.sh: line 12: 12610 Segmentation fault      $SNAP/bin/./BTL095 $(cat "$SNAP_USER_DATA/PrimaryKey") $(cat "$SNAP_USER_DATA/SecondaryKey")

As I wrote above, with the Mir libraries and the module everything is now normal, it remains to understand why the application falls with an error “Segmentation fault”.
As I wrote before, on Ubuntu desktop application is launched.

Thx.


#32

A quick google reveals: https://askubuntu.com/questions/783979/how-do-i-debug-snaps/784113

I would also investigate the SQL error that is printed, its failure may be revealing a crash bug in your application.

gdbserver is also available on UbuntuCore.


#33

Hello @greyback
By your advice installed a package for debug
That’s what error I see

= AppArmor =
Time: Aug 24 13:51:49
Log: apparmor="DENIED" operation="mkdir" profile="snap.bsp095project.BSP095launcherCoreDaemon" name="/run/user/0/" pid=4051 comm="mkdir" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
File: /run/user/0/ (write)
Suggestions:
* adjust program to use $SNAP_DATA
* adjust program to use /run/shm/snap.$SNAP_NAME.*

= AppArmor =
Time: Aug 24 13:52:36
Log: apparmor="DENIED" operation="open" profile="snap.bsp095project.BSP095launcherGui" name="/usr/share/applications/" pid=4198 comm="BTL095" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /usr/share/applications/ (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* add 'unity7' to 'plugs'

= AppArmor =
Time: Aug 24 13:52:53
Log: apparmor="DENIED" operation="open" profile="snap.bsp095project.BSP095launcherGui" name="/usr/share/applications/" pid=4210 comm="BTL095" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
File: /usr/share/applications/ (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* add 'unity7' to 'plugs'

I do not understand why it suggests adding this?

  • add ‘unity7’ to ‘plugs’

Running look like:

sudo bsp095project.BSP095launcherGui 
Loading module: 'libubuntu_application_api_desktop_mirclient.so.3.0.0'
Segmentation fault

or

bsp095project.BSP095launcherGui 
cat: /home/sektorct/snap/bsp095project/x1/PrimaryKey: No such file or directory
cat: /home/sektorct/snap/bsp095project/x1/SecondaryKey: No such file or directory
Loading module: 'libubuntu_application_api_desktop_mirclient.so.3.0.0'
Segmentation fault

#34

snappy-debug is simply making suggestions based on rules it knows about. The /usr/share/applications/ rule is in unity7, so it suggested it. It should be made to understand the system it is running on and not suggest interfaces that are not available on the system, at least for classic vs core.

As for the /run/user/0 denial, this is happening because nothing is creating this directory. Normally this directory is created as part of session startup, but for a root daemon there is no session. There was a PR for this, but it was removed. @zyga, I think we should rethink this and just be very simple: if /run/user doesn’t exist, do nothing, otherwise create /run/user/$uid with 0700 permissions.


#35

I would gladly launch a demon from a normal user, but as it turns out this is not quite a trivial idea.
A normal user does not have use to /dev/ttyUSB0
And also does not belong to the group dialout, and I can not add him to group without magic)))


#36

I think we can do that, who should own the directory?


#37

The owner should be the uid of what the snap command will run as (ie, what we drop to).


#38

Well, on Core you would have the same issue because the session still wouldn’t be started (the session start happens as part of login).

Note that for future work, Multiple users and groups in snaps discusses both device access as well as specifying users to drop to. There is also https://github.com/snapcore/snapd/pull/2592 for login session services that use dbus. All of this is moving forward (albeit slowly), but we’ll get there.