Mir-kiosk problem with rotation

Hi,
I have been using Ubuntu core for some time with mir-kiosk and electron build app. It used to work fine for my rotated screen. I added additional layout to /var/snap/mir-kiosk/current/miral-kiosk.display

layouts:
# keys here are layout labels (used for atomically switching between them)
# when enabling displays, surfaces should be matched in reverse recency order

  default:                         # the default layout

    cards:
    # a list of cards (currently matched by card-id)

    - card-id: 0
      DisplayPort-1:
        # (disconnected)

      HDMI-A-1:
        # (disconnected)

      HDMI-A-2:
        # (disconnected)

      HDMI-A-3:
        # This output supports the following modes: 1920x1080@60.0, 1920x1080@59.9,
        # 1920x1080@50.0, 1600x1200@60.0, 1680x1050@59.9, 1400x1050@59.9, 1600x900@60.0,
        # 1280x1024@75.0, 1280x1024@60.0, 1440x900@59.9, 1280x960@60.0, 1280x800@59.9,
        # 1152x864@75.0, 1280x720@60.0, 1280x720@59.9, 1280x720@50.0, 1440x576@50.0,
        # 1024x768@75.0, 1024x768@70.1, 1024x768@60.0, 1440x480@60.0, 1440x480@59.9,
        # 832x624@74.5, 800x600@75.0, 800x600@72.2, 800x600@60.3, 800x600@56.2,
        # 720x576@50.0, 720x480@60.0, 720x480@59.9, 640x480@75.0, 640x480@72.8,
        # 640x480@66.7, 640x480@60.0, 640x480@59.9, 720x400@70.1, 720x240@60.1,
        # 720x240@60.0
        #
        # Uncomment the following to enforce the selected configuration.
        # Or amend as desired.
        #
        # state: enabled        # {enabled, disabled}, defaults to enabled
        # mode: 1920x1080@60.0  # Defaults to preferred mode
        # position: [0, 0]      # Defaults to [0, 0]
        # orientation: normal   # {normal, left, right, inverted}, defaults to normal
  terminal:
          cards:
          - card-id: 0
            HDMI-A-1:
              orientation: right
            HDMI-A-2:
              orientation: right
            HDMI-A-3:
              orientation: right

and my app was rotated to right orientation and whole window was scaled to proper size. Unfortunately now, it doesn’t work like this. It flips, but doesn’t scale, part of the window is hidden.

Example of this problem:
kiosk

What has changed and what can I do to fix this ? I googled that there were some changes to mir server itself like here: https://github.com/MirServer/mir/pull/1424/commits/b114520d67993243973fb1b0f190ae211fe8aff6 , but I did not find any solution on what to add to config file.

Apart from this my touch input started to work weird. I am not sure, but I guess it is related to rotation problem.

my bet would be that someone/something played with the overscan setting on your monitor/TV, try to check its menu … there is also disable_overscan=1 that you can set in /boot/uboot/config.txt (and reboot indeed) and a few other overscan settings …

@ogra hmm I have grub instead of uboot. Are u sure this is monitor related ? I rotate terminal in grub with fbcon=rotate:1 and terminal works fine. Whole screen is used.

kiosk2

and only 4 vt with mir-kiosk display is not scaled properly.

When did this change? The last Mir release (1.8) was in April.

It should be possible to see whether Mir is picking up the layout correctly using snap logs mir-kiosk. E.g.

$ snap logs -n 200 mir-kiosk

When problems like this have been reported in the past (e.g. [cross-post] chromium-mir-kiosk in portrait mode (rotated mir-kiosk layout)) it has proved to be the client snap not rotating correctly. Could you confirm the problem is mir-kiosk with something like mir-kiosk-apps?

Hmm to be honest, it used to work fine in January, and I guess it broke around February. After that I was on vacation plus quarantine and until now I didn’t have to time to check it.

Yep, it uses my new layout.

< - debug - > miral: Display config using layout: 'terminal'

I tested it with mir-kiosk-apps and it works fine - scale properly.

I also tried to run some previous images of ubuntu core that I have with my app, but all of them now don’t scale properly.
Apart from this I tried old mir-kiosk - 1.5.0-snap93(i had it somewhere downloaded) but it seems it doesn’t work now at all. It starts, but my app gets error like “(EE) wl_display@1: error 1: invalid arguments for wl_shm@8.create_pool” and doesn’t start. I guess some other things changed too.

Is there anything that I can additionally check ? My app snap is electron based app and there were no changes in it, at least how the browser window is created.
Part of my code:

function createWindow() {
  // Create the browser window.
  let screenElectron = electron.screen;
  let displays = screenElectron.getPrimaryDisplay();
  let width = displays.workArea.width;
  let height = displays.workArea.height;

  let win = new BrowserWindow({
    width: width,
    height: height,
    kiosk: true,
    fullscreen: true,

    webPreferences: {
      nodeIntegration: false,
      preload: path.join(__dirname, "preloader.js"),
      allowRunningInsecureContent: true
    }
  });

oops, i was somehow assuming a raspberry pi, sorry :slight_smile:

1 Like

That seems to narrow the problem to your snap.

I know electron kiosks rely on a somewhat delicate arrangement of i3 and Xwayland, but as you had it working at some point I don’t see why it would fail. Maybe you could bisect the changes to your snap?

1 Like

@alan_g I did some additional research and I found this:
In mir kiosk logs I can see this:

2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438240] <information> mirserver: * Output 1: DisplayPort disconnected
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438257] <information> mirserver: * Output 2: HDMI-A disconnected
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438273] <information> mirserver: * Output 3: HDMI-A disconnected
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438288] <information> mirserver: * Output 4: HDMI-A connected, used
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438304] <information> mirserver: . |_ EDID monitor name: PL2453MT
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438319] <information> mirserver: . |_ EDID manufacturer: IVM
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438335] <information> mirserver: . |_ EDID product code: 24896
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438353] <information> mirserver: . |_ Physical size 23.4" 520x290mm
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438372] <information> mirserver: . |_ Power is on
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438391] <information> mirserver: . |_ Current mode 1920x1080 60.00Hz
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438411] <information> mirserver: . |_ Preferred mode 1920x1080 60.00Hz
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438428] <information> mirserver: . |_ Orientation right
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438445] <information> mirserver: . |_ Logical size 1080x1920
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438462] <information> mirserver: . |_ Logical position +0+0
2020-06-16T12:36:06Z mir-kiosk.daemon[2338]: [2020-06-16 12:36:06.438478] <information> mirserver: . |_ Scaling factor: 1.00

So if I understand it correctly, logical size is the size of the window electron has to draw. 1080x1920 seems good.
Then I added some logging to my snap here:

  let screenElectron = electron.screen;
  let displays = screenElectron.getPrimaryDisplay();
  let width = displays.workArea.width;
  console.log(width);
  let height = displays.workArea.height;
  console.log(height);

and logs show this:

2020-06-16T12:36:13Z terminal-app.daemon[6012]: 1920
2020-06-16T12:36:13Z terminal-app.daemon[6012]: 1080

So it looks that electron does not get proper width and height from display. Maybe a bug in electron ?
Did I get it right ? or maybe something else ?

I know nothing about writing applications with Electron. Is there perhaps a displays.orientation you need to consider in interpreting displays.workArea.width correctly?

There is:

rotation Number - Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.

But unfortunately it shows 0. It thinks it is not rotated. Eh. I guess I am out of ideas.

Hi @PiotrD,

I was able to solve the exact same issue by updating mir-kiosk.

$: snap refresh mir-kiosk --channel=latest/edge
$: mir-kiosk (edge) 2.0.0.0+dev137-snap94 from Canonicalâś“ refreshed

I hope this solves your problem too.