[performance] Touch scrolling is stuttery under Unity8 (but only while you're touching it)

Bug #1486341 reported by Daniel van Vugt
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
qtmir (Ubuntu)
Won't Fix
Undecided
Unassigned
unity8 (Ubuntu)
Fix Released
Undecided
Daniel van Vugt

Bug Description

Touch scrolling is stuttery under Unity8 (but only while you're touching it).

I noticed that Unity8 is smooth in some parts and stutters in others. Turns out the smooth parts of Unity8 like the indicators pull-down and app switcher are the parts that don't have to run as clients of the nested server. I also noticed that those stuttering clients (like the dash) of the nested server only stutter while you're touching them. They animate smoothly if you fling them lifting your finger off, but stutter while they have to track your finger.

Turns out the problem is Qt's built-in input resampling introduced in Qt 5.4 (commit 6dc8f47bb05a8acb3cbcc697e0dc05356a01d4cf). Turning it off in the unity8 process (env QML_NO_TOUCH_COMPRESSION=1) fixes the touch scrolling smoothness problem for clients like unity8-dash.

I suspected this would be the case. It's possible the Qt resampling implementation doesn't work when nested. That would be unsurprising, having implemented Mir's input resampling I know that can be a problem. Although Mir's input resampling is designed in such a way that performance is unaffected by nesting. The below test case and also:
  https://bugreports.qt.io/browse/QTBUG-40167 (maybe unrelated)
both suggest that the Qt input resampling introduced by Jolla is causing stuttering, particularly when nested in a situation where the incoming touch events are already throttled...

Measurements from arale:

restart unity8-dash MIR_CLIENT_PERF_REPORT=log
tail -f ~/.cache/upstart/unity8-dash.log

[1439957791.298680] perf: Scopes: 52.42 FPS, render time 17.90ms, buffer lag 39.37ms (3 buffers)
[1439957792.303939] perf: Scopes: 54.72 FPS, render time 17.07ms, buffer lag 37.57ms (3 buffers)
[1439957793.316036] perf: Scopes: 55.33 FPS, render time 16.82ms, buffer lag 36.90ms (3 buffers)
[1439957794.329848] perf: Scopes: 56.26 FPS, render time 16.21ms, buffer lag 37.69ms (3 buffers)
[1439957795.335884] perf: Scopes: 52.68 FPS, render time 18.05ms, buffer lag 38.87ms (3 buffers)
[1439957796.343125] perf: Scopes: 51.63 FPS, render time 18.03ms, buffer lag 40.15ms (3 buffers)
[1439957797.360229] perf: Scopes: 54.08 FPS, render time 17.41ms, buffer lag 38.04ms (3 buffers)
[1439957798.370706] perf: Scopes: 54.45 FPS, render time 17.18ms, buffer lag 37.99ms (3 buffers)
[1439957799.401308] perf: Scopes: 53.39 FPS, render time 17.79ms, buffer lag 37.43ms (3 buffers)

restart unity8 QML_NO_TOUCH_COMPRESSION=1
restart unity8-dash MIR_CLIENT_PERF_REPORT=log
tail -f ~/.cache/upstart/unity8-dash.log

[1439957936.543370] perf: Scopes: 59.64 FPS, render time 15.52ms, buffer lag 34.48ms (3 buffers)
[1439957937.543547] perf: Scopes: 59.00 FPS, render time 16.36ms, buffer lag 34.26ms (3 buffers)
[1439957938.571699] perf: Scopes: 59.33 FPS, render time 16.26ms, buffer lag 34.22ms (3 buffers)
[1439957939.572860] perf: Scopes: 59.94 FPS, render time 15.76ms, buffer lag 34.32ms (3 buffers)
[1439957940.581339] perf: Scopes: 62.50 FPS, render time 14.68ms, buffer lag 33.75ms (3 buffers)
[1439957941.594696] perf: Scopes: 59.23 FPS, render time 14.81ms, buffer lag 35.83ms (3 buffers)
[1439957942.597224] perf: Scopes: 61.87 FPS, render time 14.64ms, buffer lag 33.96ms (3 buffers)
[1439957943.612315] perf: Scopes: 61.08 FPS, render time 14.59ms, buffer lag 34.39ms (3 buffers)
[1439957944.625835] perf: Scopes: 60.21 FPS, render time 15.79ms, buffer lag 34.28ms (3 buffers)

Tags: performance

Related branches

description: updated
description: updated
description: updated
description: updated
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Mako also benefits a bit:

restart unity8-dash MIR_CLIENT_PERF_REPORT=log
tail -f ~/.cache/upstart/unity8-dash.log

[1439963004.335110] perf: Scopes: 53.83 FPS, render time 16.29ms, buffer lag 39.79ms (3 buffers)
[1439963005.338590] perf: Scopes: 54.83 FPS, render time 16.02ms, buffer lag 38.80ms (3 buffers)
[1439963006.340451] perf: Scopes: 55.94 FPS, render time 16.14ms, buffer lag 36.86ms (3 buffers)
[1439963007.351133] perf: Scopes: 47.52 FPS, render time 19.31ms, buffer lag 43.84ms (3 buffers)
[1439963008.363494] perf: Scopes: 57.31 FPS, render time 15.04ms, buffer lag 37.34ms (3 buffers)
[1439963009.384706] perf: Scopes: 56.80 FPS, render time 16.13ms, buffer lag 36.59ms (3 buffers)
[1439963010.451729] perf: Scopes: 49.67 FPS, render time 18.56ms, buffer lag 39.77ms (3 buffers)
[1439963011.457985] perf: Scopes: 58.64 FPS, render time 15.30ms, buffer lag 38.11ms (3 buffers)
[1439963012.468362] perf: Scopes: 56.43 FPS, render time 16.90ms, buffer lag 36.48ms (3 buffers)

restart unity8 QML_NO_TOUCH_COMPRESSION=1
restart unity8-dash MIR_CLIENT_PERF_REPORT=log
tail -f ~/.cache/upstart/unity8-dash.log

[1439963121.853194] perf: Scopes: 61.87 FPS, render time 12.15ms, buffer lag 36.61ms (3 buffers)
[1439963122.863754] perf: Scopes: 59.40 FPS, render time 10.45ms, buffer lag 40.20ms (3 buffers)
[1439963123.866348] perf: Scopes: 59.88 FPS, render time 14.06ms, buffer lag 36.28ms (3 buffers)
[1439963124.875901] perf: Scopes: 60.45 FPS, render time 10.91ms, buffer lag 38.34ms (3 buffers)
[1439963125.930898] perf: Scopes: 55.97 FPS, render time 12.45ms, buffer lag 39.29ms (3 buffers)
[1439963126.976923] perf: Scopes: 59.27 FPS, render time 12.67ms, buffer lag 38.09ms (3 buffers)
[1439963128.001339] perf: Scopes: 60.54 FPS, render time 11.60ms, buffer lag 39.43ms (3 buffers)
[1439963129.009977] perf: Scopes: 61.50 FPS, render time 12.01ms, buffer lag 36.53ms (3 buffers)
[1439963130.014616] perf: Scopes: 55.77 FPS, render time 14.85ms, buffer lag 39.11ms (3 buffers)

description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in qtmir (Ubuntu):
status: New → Confirmed
Changed in unity8 (Ubuntu):
status: New → Confirmed
tags: added: performance
summary: - Touch scrolling is stuttery under Unity8 (but only while you're touching
- it)
+ [performance] Touch scrolling is stuttery under Unity8 (but only while
+ you're touching it)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yes, using just Mir's 59Hz input rate by itself would appear to solve this bug. However looking ahead we need a different solution. Because we'll soon be ready to re-enable Mir's dynamic queue scaling that can provide significantly lower latency. However for touch-driven apps it only works when the input rate is at least that of the display. So we need Mir's input rate raised to 60Hz, or to fix the Qt touch compression and use that instead (non-nested, so only in unity8 but not apps).

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Considering also related bug 1497105 and bug 1488386, I think all three would benefit from us removing input resampling completely from the top-level (unity8 process) via:
   QML_NO_TOUCH_COMPRESSION=1
   MIR_CLIENT_INPUT_RATE=0

That would immediately solve this bug, and bug 1497105, and partially solve the keep-awake problem of bug 1488386.

The only issue then is to make sure shell elements are still responsive in the presence of high frequency input events. Apps themselves would not be affected because they already have their own resampling.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Annoyingly, in order to reliably set QML_NO_TOUCH_COMPRESSION, you have to do it in the parent process before unity8 or the Qt client is launched. Because it's only checked once on static initialization:

static bool qquickwindow_no_touch_compression = qEnvironmentVariableIsSet("QML_NO_TOUCH_COMPRESSION");

So whatever is launching unity8 (upstart job?) has to set QML_NO_TOUCH_COMPRESSION. And the same goes for Qt apps.

Changed in unity8 (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
status: Confirmed → In Progress
Changed in qtmir:
status: New → Won't Fix
Changed in qtmir (Ubuntu):
status: Confirmed → Won't Fix
no longer affects: qtmir
Michał Sawicz (saviq)
Changed in unity8 (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.