[vivid-overlay] unity8 fails to start on the emulator

Bug #1458694 reported by Ricardo Salveti on 2015-05-25
40
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Critical
Pat McGowan
ubuntu-ui-toolkit (Ubuntu)
Critical
Tim Peeters
unity8 (Ubuntu)
Undecided
Michael Terry

Bug Description

phablet@ubuntu-phablet:~$ system-image-cli -i
current build number: 140
device name: generic_x86
channel: ubuntu-touch/rc-proposed/ubuntu
last update: 2015-05-25 12:02:10
version version: 140
version ubuntu: 20150525
version device: 20150210
version custom: 20150525

When starting unity8 (this started at image 136, probably when mir 0.13 landed):

phablet@ubuntu-phablet:~$ cat ./.cache/upstart/unity8.log
()
[1432595001.896139] mirplatform: Found graphics driver: dummy
[1432595001.898447] mirplatform: Found graphics driver: android
qtmir.mir: MirServer created
[1432595003.675225] Server: Starting
[1432595003.679331] Loader: Loading modules from: /usr/lib/i386-linux-gnu/mir/server-platform
[1432595003.679501] Loader: Loading module: /usr/lib/i386-linux-gnu/mir/server-platform/graphics-dummy.so
[1432595003.680673] Loader: Loading module: /usr/lib/i386-linux-gnu/mir/server-platform/input-stub.so
[1432595003.681107] <WARNING> Loader: Failed to load module: /usr/lib/i386-linux-gnu/mir/server-platform/input-stub.so (error was:/usr/lib/i386-linux-gnu/mir/server-platform/input-stub.so: undefined symbol: _ZN3mir6events10make_eventExx17MirKeyboardActionjij)
[1432595003.684868] Loader: Loading module: /usr/lib/i386-linux-gnu/mir/server-platform/graphics-android.so.2
[1432595003.685014] mirplatform: Found graphics driver: dummy
[1432595003.685211] mirplatform: Found graphics driver: android
[1432595003.685416] Platform Loader: Selected driver: android (version 0.13.0)
qtmir.mir: PromptSessionListener::PromptSessionListener - this= PromptSessionListener(0x9679764)
qtmir.mir: SessionListener::SessionListener - this= SessionListener(0x9676d24)
qtmir.mir: MirShell::MirShell
[1432595003.883766] DisplayServer: Mir version 0.13.0
QtCompositor::setAllWindowsExposed true
qtmir.clipboard: D-Bus registration successful.
Mode argument was not provided or was set to an illegal value. Using default value of --mode= "full-greeter"
Cannot create window: no screens available

With version 135 it starts fine, but not fully functional, giving this error:

QOpenGLShader::compile(Fragment): 0:2(12): warning: extension `GL_OES_standard_derivatives' unsupported in fragment shader
0:2(1): error: #extension directive is not allowed in the middle of a shader

*** Problematic Fragment shader source code ***
#extension GL_OES_standard_derivatives : enable // Enable dFdy() on OpenGL ES 2.
#define lowp
#define mediump
#define highp

// Copyright © 2015 Canonical Ltd.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Author: Loïc Molinari <email address hidden>

// Static flow control (branching on a uniform value) is fast on most GPUs (including ultra-low
// power ones) because it allows to use the same shader execution path for an entire draw call. We
// rely on that technique here (also known as "uber-shader" solution) to avoid the complexity of
// dealing with a multiple shaders solution.
// FIXME(loicm) Validate GPU behavior with regards to static flow control.

uniform sampler2D shapeTexture;
uniform sampler2D sourceTexture;
uniform lowp vec2 dfdtFactors;
uniform lowp vec2 opacityFactors;
uniform lowp float sourceOpacity;
uniform lowp float distanceAA;
uniform bool textured;
uniform mediump int aspect;

varying mediump vec2 shapeCoord;
varying mediump vec4 sourceCoord;
varying lowp vec4 backgroundColor;

const mediump int FLAT = 0x08; // 1 << 3
const mediump int INSET = 0x10; // 1 << 4

void main(void)
{
    lowp vec4 shapeData = texture2D(shapeTexture, shapeCoord);
    lowp vec4 color = backgroundColor;

    // FIXME(loicm) Would be better to use a bitfield but bitwise ops have only been integrated in
    // GLSL 1.3 (OpenGL 3) and GLSL ES 3 (OpenGL ES 3).
    if (textured) {
        // Blend the source over the current color.
        // FIXME(loicm) sign() is far from optimal. Call texture2D() at beginning of scope.
        lowp vec2 axisMask = -sign((sourceCoord.zw * sourceCoord.zw) - vec2(1.0));
        lowp float mask = clamp(axisMask.x + axisMask.y, 0.0, 1.0);
        lowp vec4 source = texture2D(sourceTexture, sourceCoord.st) * vec4(sourceOpacity * mask);
        color = vec4(1.0 - source.a) * color + source;
    }

    // Get screen-space derivative of texture coordinate t representing the normalized distance
    // between 2 pixels. dFd*() unfortunately have to be called outside of branches in order to work
    // correctly with VMware's "Gallium 0.4 on SVGA3D".
    lowp vec2 derivatives = vec2(dFdx(shapeCoord.t), dFdy(shapeCoord.t));
    lowp float dfdt = dfdtFactors.x != 0.0 ? derivatives.x : derivatives.y;

    if (aspect == FLAT) {
        // Mask the current color with an anti-aliased and resolution independent shape mask built
        // from distance fields.
        lowp float distanceMin = abs(dfdt) * -distanceAA + 0.5;
        lowp float distanceMax = abs(dfdt) * distanceAA + 0.5;
        color *= smoothstep(distanceMin, distanceMax, shapeData.b);

    } else if (aspect == INSET) {
        // The vertex layout of the shape is made so that the derivative is negative from top to
        // middle and positive from middle to bottom.
        lowp float shapeSide = dfdt * dfdtFactors.y <= 0.0 ? 0.0 : 1.0;
        // Blend the shape inner shadow over the current color. The shadow color is black, its
        // translucency is stored in the texture.
        lowp float shadow = shapeData[int(shapeSide)];
        color = vec4(1.0 - shadow) * color + vec4(0.0, 0.0, 0.0, shadow);
        // Get the anti-aliased and resolution independent shape mask using distance fields.
        lowp float distanceMin = abs(dfdt) * -distanceAA + 0.5;
        lowp float distanceMax = abs(dfdt) * distanceAA + 0.5;
        lowp vec2 mask = smoothstep(distanceMin, distanceMax, shapeData.ba);
        // Get the bevel color. The bevel is made of the top mask masked with the bottom mask. A
        // gradient from the bottom (1) to the middle (0) of the shape is used to factor out values
        // resulting from the mask anti-aliasing. The bevel color is white with 60% opacity.
        lowp float bevel = (mask.x * -mask.y) + mask.x; // -ab + a = a(1 - b)
        lowp float gradient = clamp((shapeSide * -shapeCoord.t) + shapeSide, 0.0, 1.0);
        bevel *= gradient * 0.6;
        // Mask the current color then blend the bevel over the resulting color. We simply use
        // additive blending since the bevel has already been masked.
        color = (color * vec4(mask[int(shapeSide)])) + vec4(bevel);
    }

    gl_FragColor = color * opacityFactors.xxxy;
}

***
shader compilation failed:
""

Adb is broken because of bug 1458043, so use the following workaround to get it to work again:

$ sudo ubuntu-emulator create --channel=ubuntu-touch/rc-proposed/ubuntu test_x86 --use-raw-disk
$ mkdir -p /tmp/mount1 /tmp/mount2
$ sudo mount ~/.local/share/ubuntu-emulator/test_x86/sdcard.img /tmp/mount1
$ sudo mount /tmp/mount1/system.img /tmp/mount2
$ sudo vi /tmp/mount2/var/lib/lxc/android/pre-start.d/20-no-default-prop-adb
#! /bin/sh

# Avoid changing the the property when running on the emulator
if ! grep -q "qemu=1" /proc/cmdline; then
    sed -i '/^persist.sys.usb.config=.*/d' $LXC_ROOTFS_PATH/default.prop || true
fi
$ sudo umount /tmp/mount2
$ sudo umount /tmp/mount1

Related branches

Changed in mir (Ubuntu):
importance: Undecided → Critical
Changed in ubuntu-ui-toolkit (Ubuntu):
importance: Undecided → High
Zsombor Egri (zsombi) on 2015-05-26
Changed in ubuntu-ui-toolkit (Ubuntu):
status: New → Triaged
importance: High → Critical
assignee: nobody → Loïc Molinari (loic.molinari)
Changed in canonical-devices-system-image:
assignee: nobody → Pat McGowan (pat-mcgowan)
importance: Undecided → Critical
milestone: none → ww28-2015
status: New → Confirmed
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mir (Ubuntu):
status: New → Confirmed
tags: added: lt-blocker lt-category-visible
Daniel van Vugt (vanvugt) wrote :

We claim to have fixed this; duplicate of bug 1458689 with a fix coming in release 0.14.0.

Please update the other bug if the fix is insufficient.

kevin gunn (kgunn72) wrote :

removing duplication after some brief discussion, shader issue is separate from input stub loading

Changed in mir (Ubuntu):
assignee: nobody → Andreas Pokorny (andreas-pokorny)
Changed in canonical-devices-system-image:
milestone: ww28-2015 → ww34-2015
Alberto Aguirre (albaguirre) wrote :

The input stub error message is inconsequential, mir is simply scanning all the modules in that directory and finds the appropriate one: "[1432595003.685416] Platform Loader: Selected driver: android (version 0.13.0)"

The real issue is Qt not being able to create a window: "Cannot create window: no screens available"

I suspect qtmir does not create any screens maybe because mir's DisplayConfigurationOutput does not enumerate any outputs.
A run of mir-out inside the emulator should provide some initial leads.

kevin gunn (kgunn72) wrote :

So this was 2 bugs conflated it seems.
There was a warning/err for the input-stub in mir, that is actually covered and has a fix committed under this bug 1458689 (branch now attached here as well)

The second issue it seems is that the uitk via qt is asking for a shader extension to be used that is likely not supported by the emulator graphics platform. This will most likely need to have an error check added in order to accomodate the failure and use an alternate shader program (e.g. one without needing the extension)

Changed in mir:
importance: Undecided → Critical
status: New → Confirmed
assignee: nobody → Andreas Pokorny (andreas-pokorny)
Daniel van Vugt (vanvugt) wrote :

Yep, the remaining issue seems to be these shader functions:
    dFdx()
    dFdy()
    fwidth()
which are from GL_OES_standard_derivatives, that is not implemented by all drivers/platforms.

That shader code is not in Mir BTW. This bug no longer has anything to do with Mir since the first issue was separated into bug 1458689.

We need a fallback (or to avoid uncommon extensions) for the sake of portability.

Changed in mir:
status: Confirmed → Invalid
Changed in mir (Ubuntu):
status: Confirmed → Invalid
Daniel van Vugt (vanvugt) wrote :

To clarify; the remaining issue is the shader code in ubuntu-ui-toolkit. It's not in Mir.

Loïc Molinari (loic.molinari) wrote :

The UbuntuShape in the UITK requires support for standard derivatives in shaders so that it can nicely anti-alias distance fields (for the corners) under any scale factor. It's quite unfortunate that the emulator doesn't support that extension... I'll try to find a workaround though.

Daniel van Vugt (vanvugt) wrote :

Sounds like an expensive way of doing things. Is there a reason why we can't just render standard toolkit elements as very high res textures and use good old texture minification with GL_LINEAR filtering? That's both fast and portable, because OpenGL has had it since last century :)

A couple of examples where we do so in Mir demos:
http://bazaar.launchpad.net/~mir-team/mir/development-branch/view/head:/playground/demo-shell/demo_renderer.cpp

Daniel van Vugt (vanvugt) wrote :

Oh, QML wants shaders. I forgot.

Loïc Molinari (loic.molinari) wrote :

Daniel, relying on HW texture minification (or magnification) filters is fast but quite ugly in terms of contour anti-aliasing quality. Using distance fields instead allows for instance to have a 16x16 contour texture that can be rendered at 256x256 at perfect quality. It just requires a texture lookup and a smoothstep(). Retrieving the standard derivatives is almost free since the 4 texels required for the subtraction have already been fetched during the texture lookup (so still cached). It is the perfect thing for the shape since we need to get the shape mask under any scale factor as required by our grid unit system.

This technique has been used for a decade now and is efficient, easy to implement and lightweigth in terms of texture usage. This is for instance also used by QML for text rendering. More info can be found there : http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

Daniel van Vugt (vanvugt) wrote :

I don't think it always has to look ugly. If your original texture is sufficiently smooth then the accuracy of the the hardware minification (or even using GL_NEAREST) is not a significant factor. That said, I was a bit lazy and used the same approach on the titlebar text and that's indeed a bit ugly. Elements that don't need pixel-sized fineness however actually end up quite nice. If we had a UI design with fewer thin lines it would be quite feasible.

Loïc Molinari (loic.molinari) wrote :

Agreed. But we tested that and the best trade-off between quality and performance for our use-case is that distance field technique. It seems I'll have to provide a lower quality fallback using that technique though...

Changed in canonical-devices-system-image:
status: Confirmed → In Progress
kevin gunn (kgunn72) on 2015-08-11
no longer affects: mir
no longer affects: mir (Ubuntu)
Changed in ubuntu-ui-toolkit (Ubuntu):
status: Triaged → In Progress
Tim Peeters (tpeeters) on 2015-08-18
Changed in ubuntu-ui-toolkit (Ubuntu):
assignee: Loïc Molinari (loic.molinari) → Tim Peeters (tpeeters)
Gerry Boland (gerboland) wrote :

Emulator faling also because of https://bugs.launchpad.net/mir/+bug/1486535

Tim Peeters (tpeeters) on 2015-08-21
Changed in ubuntu-ui-toolkit (Ubuntu):
status: In Progress → Fix Committed
Timo Jyrinki (timo-jyrinki) wrote :

As per QA report:
"Needs a fix in unity8 so we can get past edges demo and confirm there are no further issues with the silo before landing."

This is now fixed from UITK and Mir points of view. The remaining issue is that Unity 8 needs to automatically skip the edges demo when used inside the emulator.

kevin gunn (kgunn72) on 2015-08-21
Changed in unity8 (Ubuntu):
status: New → Fix Committed
assignee: nobody → Michael Terry (mterry)
Changed in canonical-devices-system-image:
status: In Progress → Fix Committed

On Fri, Aug 21, 2015 at 6:52 AM, Timo Jyrinki
<email address hidden> wrote:
> As per QA report:
> "Needs a fix in unity8 so we can get past edges demo and confirm there are no further issues with the silo before landing."

Sorry, but why do we need to disable the edge demo? It's still useful
during the first boot. If needed we could extend the flashing tool to
offer an option for that.

Michael Terry (mterry) wrote :

> Sorry, but why do we need to disable the edge demo?

We disabled the tutorial in desktop mode only. We had in the past disabled part of it on the desktop (because certain drag-widgets didn't work with mice). But this change drops the whole thing (which was at this point, just the left-edge drag). To my knowledge, we're still waiting on design for visuals for a desktop tutorial.

The real bug is that the emulator is starting in desktop mode. And seems to have some issues with using -mousetouch to emulate a touch device.

But at least disabling the tutorial in desktop mode gets *some* sort of emulator functionality in the short term.

Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-ui-toolkit - 1.3.1603+15.10.20150824.1-0ubuntu1

---------------
ubuntu-ui-toolkit (1.3.1603+15.10.20150824.1-0ubuntu1) wily; urgency=medium

  [ CI Train Bot ]
  * Resync trunk. added: po/eo.po

  [ Christian Dywan ]
  * Make deprecation warnings from C++ opt-in (LP: #1467851)

 -- CI Train Bot <email address hidden> Mon, 24 Aug 2015 20:49:45 +0000

Changed in ubuntu-ui-toolkit (Ubuntu):
status: Fix Committed → Fix Released
Changed in unity8 (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers