Unity8/Mir is unable to open autopilot uinput devices
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mir |
Fix Released
|
Critical
|
Robert Carr | ||
mir (Ubuntu) |
Fix Released
|
Undecided
|
Robert Carr |
Bug Description
When running unity8 on top of mir, the input events generated by autopilot have no effect on the application under test. I've spent the best part of a day debugging this, so what follows is a brain dump of everything we've tried, so others can continue the effort while I sleep.
Basic Notes:
===========
To run the autopilot tests, there are a few things you need to do - these steps all need to be run as the phablet user (from the host, run: "adb shell" then "sudo -i -u phablet"):
0) If it hasn't already made it into the image, install the patched python-
1) Get the test cases. From the host, run 'phablet-
2) Switch to running mir: "touch ~phablet/
3) Install the test dependencies. In this example I'll use the ubuntu ui toolkit test suite:
sudo apt-get install ubuntu-
4) Unlike surface flinger, you *must* have the unity8 shell running when trying to run a test suite. This is becasue without unity8, there's no display server, so you can't launch any applications. This caught me out for a while, because the error message you get isn't particularly intuitive.
5) Now you can run the test. Unlock the unity shell (i.e.- make sure it's not on the greeter) and then I recommend just running a single test:
cd ~/autopilot
autopilot run -v ubuntuuitoolkit
The test will fail because the input events never make it through to the application.
Debugging mir:
=============
If you export some environment variables...
initctl set-env MIR_SERVER_
initctl set-env MIR_SERVER_
and then restart unity8 (so those environment variables are picked up), then re-run the autopilot test, you'll get additional log output from mir in ~/.cache/
If you run those tests again, you'll see two messages like this:
[EE, android-input] [EventHub]could not open /dev/input/event6, Permission denied
[EE, android-input] [EventHub]could not open /dev/input/event7, Permission denied
This is mir finding the new device nodes that autopilot creates, but failing to open them.
I ran unity8 under strace, and the resulting log file is here:
http://
It's a large log file, but the relevant sections are:
6214 open("/
6214 <... open resumed> ) = -1 EACCES (Permission denied)
Note that, at this point, you probably want an easier way to reproduce this than running the entire autopilot test. You can simply run this in a shell:
python -c "from time import sleep; from autopilot.input import Touch; t = Touch.create(); sleep(60)"
Debugging Permissions:
=======
So it looks like a file permissions problem. We've looked at the following:
i) The file permissions in the ubuntu-side:
$ ls -l /dev/input/event*
crw-rw---- 1 root android_input 13, 64 Oct 1 23:37 /dev/input/event0
crw-rw---- 1 root android_input 13, 65 Oct 1 23:37 /dev/input/event1
crw-rw---- 1 root android_input 13, 66 Oct 1 23:37 /dev/input/event2
crw-rw---- 1 root android_input 13, 67 Oct 1 23:37 /dev/input/event3
crw-rw---- 1 root android_input 13, 68 Oct 1 23:37 /dev/input/event4
crw-rw---- 1 root android_input 13, 69 Oct 1 23:37 /dev/input/event5
crw-rw---- 1 root android_input 13, 70 Oct 2 02:36 /dev/input/event6
crw-rw---- 1 root android_input 13, 71 Oct 2 02:36 /dev/input/event7
ii) The permissions android-side:
$ sudo android-chroot
root@android:/ # ls -l /dev/input/event*
crw-rw---- root input 13, 64 2013-10-01 23:37 event0
crw-rw---- root input 13, 65 2013-10-01 23:37 event1
crw-rw---- root input 13, 66 2013-10-01 23:37 event2
crw-rw---- root input 13, 67 2013-10-01 23:37 event3
crw-rw---- root input 13, 68 2013-10-01 23:37 event4
crw-rw---- root input 13, 69 2013-10-01 23:37 event5
crw-rw---- root input 13, 70 2013-10-02 02:36 event6
crw-rw---- root input 13, 71 2013-10-02 02:36 event7
iii) We've verified that this is not apparmor doing something to us:
$ grep DENIED /var/log/syslog
Other Interesting Things:
=======
If we create the autopilot touch device before unity8 starts, then mir is able to open the device nodes just fine. This suggests to me that:
- it's not something to do with these devices being uinput, rather than "real" devices.
The code that opens this device is (in lp:mir HEAD)
3rd_party/
~~~
int fd = open(devicePath, O_RDWR | O_CLOEXEC);
if(fd < 0) {
ALOGE("could not open %s, %s\n", devicePath, strerror(errno));
return -1;
}
~~~
I wondered if the open mode flags were causing a problem, but a simple program that opens the same device in the same way works perfectly.
Current Suspicions:
=================
The big clue here seems to be that mir can open all devices when it starts, but fails to open devices that are created later. Perhaps:
- mir has fewer priviledges / permissions later, than it does when it starts up?
- perhaps there's a race condition, and both mir *and* something else are trying to access the same device node at the same time, and this is somehow causing problems.
Related branches
- Robert Carr (community): Needs Fixing
- PS Jenkins bot: Pending (continuous-integration) requested
-
Diff: 27 lines (+9/-1)1 file modified3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp (+9/-1)
- PS Jenkins bot (community): Approve (continuous-integration)
- Robert Ancell: Approve
-
Diff: 65 lines (+24/-1)2 files modified3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp (+23/-1)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.h (+1/-0)
- Daniel d'Andrada (community): Disapprove
- PS Jenkins bot (community): Approve (continuous-integration)
- kevin gunn (community): Approve
- Kevin DuBois (community): Abstain
- Robert Ancell: Approve
- Robert Carr (community): Abstain
-
Diff: 65 lines (+24/-1)2 files modified3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp (+23/-1)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.h (+1/-0)
description: | updated |
description: | updated |
description: | updated |
Changed in mir: | |
assignee: | nobody → Daniel d'Andrada (dandrader) |
status: | New → In Progress |
Changed in mir: | |
assignee: | Daniel d'Andrada (dandrader) → Robert Carr (robertcarr) |
Changed in mir (Ubuntu): | |
assignee: | nobody → Robert Carr (robertcarr) |
Should have mentioned - this is using the devel-proposed ubuntu-system image.