Docs: Your First Snap webcam-webui does not work once installed

Bug #1609577 reported by Jeff Lane
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Snapcraft
Undecided
Unassigned

Bug Description

The example webcam-webui does not work after installing the built snap.

 https://developer.ubuntu.com/en/snappy/build-apps/your-first-snap/

This seems to be because the walkthrough doesn't cover interfaces, nor how to connect your snap to those interfaces. Since the walkthrough uses the camera interface, this should be part of the instructions.

When trying to use the snap (note the instructions ALSO say we should use strict confinement in snapcraft.yaml), the following appears in syslog:

Aug 3 19:10:57 galactica ubuntu-core-launcher[12684]: #033[0m#033[1m--- Opening /dev/video0...
Aug 3 19:10:57 galactica ubuntu-core-launcher[12684]: #033[0m#033[0mTrying source module v4l2...
Aug 3 19:10:57 galactica ubuntu-core-launcher[12684]: #033[0m#033[31mError opening device: /dev/video0
Aug 3 19:10:57 galactica ubuntu-core-launcher[12684]: #033[0m#033[31mopen: Permission denied
Aug 3 19:10:57 galactica ubuntu-core-launcher[12684]: #033[0m#033[0mTrying source module v4l1...
Aug 3 19:10:57 galactica ubuntu-core-launcher[12684]: #033[0m#033[31mError opening device: /dev/video0
Aug 3 19:10:57 galactica kernel: [66880.927735] audit: type=1400 audit(1470265857.619:126679): apparmor="DENIED" operation="open" profile="snap.webcam-webui.webcam-webui" name="/dev/video0" pid=13030 comm="fswebcam" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
Aug 3 19:10:57 galactica kernel: [66880.927803] audit: type=1400 audit(1470265857.619:126680): apparmor="DENIED" operation="open" profile="snap.webcam-webui.webcam-webui" name="/dev/video0" pid=13030 comm="fswebcam" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0

I'm still trying to figure out how to make this snap talk to my webcam.

Additionally, the webserver itself is not accessible. The snap either doesn't start the go webserver, or it's just not listening.

The walkthrough indicates it should be port 8080:

panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("."))))

but trying to connect to localhost (I'm running this on Xenial) fails to connect.

Revision history for this message
Leo Arias (elopio) wrote :

This should have been fixed with the change in the bug marked as duplicate. Please check and reopen if you are still having problems with snapcraft 2.14.

Thank you!

Revision history for this message
Jeff Lane (bladernr) wrote :

This was NOT fixed, here's a copy of my comment in 1603895:
My bug was marked a dupe of this. This is NOT fixed. Using snapcraft 2.14 and a fresh clone of the git tree, I went to snapcraft/demos/webcam-webui.

From there I staged and built the snap, then installed the snap. After the snap is installed, Interfaces shows that the demo is plugged into the network-bind interface, but the camera plug is not connected to the camera slot.

bladernr@galactica:~/development/snappy/snapcraft/demos/webcam-webui$ snapcraft --version
2.14
bladernr@galactica:~/development/snappy/snapcraft/demos/webcam-webui$ snap interfaces
Slot Plug
:camera -
:cups-control -
:firewall-control -
:gsettings -
:hardware-observe -
:home -
:locale-control -
:log-observe -
:modem-manager -
:mount-observe -
:network webdm
:network-bind webcam-webui,webdm
:network-control -
:network-manager -
:network-observe -
:opengl -
:optical-drive -
:ppp -
:pulseaudio -
:snapd-control webdm
:system-observe -
:timeserver-control -
:timezone-control -
:unity7 -
:x11 -
- webcam-webui:camera

For whatever reason, the snap does make the connection to network-bind on install but does NOT create the connection to the camera slot, that still has to be done manually.

Additionally, per my original bug, the walkthrough on our website:
https://developer.ubuntu.com/en/snappy/build-apps/your-first-snap/

does not match this demo at all, especially after the recent modifications to the demo in git.

So, summary:

1: The Your First Snap web page is still broken.
2: The doc https://github.com/snapcore/snapcraft/blob/master/docs/your-first-snap.md is still broken
3: The webcam-webui demo is still broken.

Revision history for this message
Jeff Lane (bladernr) wrote :

I am not able to re-open 1603895, so I'm re-opening this one.

Revision history for this message
Dev (devtobo) wrote :

I have also this problem with my application:

snap interfaces
Slot Plug
:camera -
...
- myapp:camera

Is there a way to make this works while waiting a fix to snapcraft?
Thanks

Revision history for this message
Dev (devtobo) wrote :

When trying to:
sudo snap connect myapp:camera ubuntu-core:camera

I have this error:
error: snap "ubuntu-core" has no slot named "camera"

Revision history for this message
Dev (devtobo) wrote :

Finally someone on IRC told me to use:
sudo snap connect myapp:camera

It works, but how to make it works out-of-the-box without asking my users to run this command?

Revision history for this message
Dev (devtobo) wrote :

Ok more people helped on IRC and as today, there's no out-of-the-box solution... I need to ask my user to run sudo snap connect myapp:camera - even when they use the software center (so no terminal involve).

Is there any plan to make it works out-of-the-box (snap install myapp = webcam works or Software Center, Search myapp, Install = webcam works)?

Revision history for this message
XiaoGuo, Liu (liu-xiao-guo) wrote :

If you take a look at the document at:

https://snapcraft.io/docs/reference/interfaces

camera interface is not auto-connected. You need to connect it manually. You have to use the following commands:

sudo snap connect myapp:camera ubuntu-core:camera

or

sudo snap connect myapp:camera core:camera

depending on whether "ubuntu-core" or "core" is installed on your device. You may use "snap list" to find out.

By the way, I have made it working for desktop and raspberry pi.

Best regards,
XiaoGuo

Revision history for this message
Oliver Grawert (ogra) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers