Bug 361674 - X11 damage events not generated when the desktop is exposed
Summary: X11 damage events not generated when the desktop is exposed
Status: RESOLVED NOT A BUG
Alias: None
Product: plasmashell
Classification: Plasma
Component: Containment (show other bugs)
Version: 5.5.4
Platform: Ubuntu Linux
: NOR normal
Target Milestone: 1.0
Assignee: Sebastian Kügler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-12 15:37 UTC by mcottrell
Modified: 2018-08-09 23:25 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
damage monitoring utility (3.02 KB, text/x-c++src)
2016-04-12 15:38 UTC, mcottrell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mcottrell 2016-04-12 15:37:19 UTC
When exposing the desktop, e.g. show desktop or minimising the only visible window, damage events are not generated for the majority of the desktop. Currently I'm only seeing damage for the bottom 36 pixels.

Reproducible: Always

Steps to Reproduce:
1. monitor damage events
2. open a full screen konsole instance
3. expose the desktop

Actual Results:  
damage events are only generated for the bottom 36 pixels of the display:

--------- damage event ----------
area:     x: 0, y: 1164, w: 1920, h: 34
geometry: x: 0, y: 0, w: 1920, h: 1200
--------- damage event ----------
area:     x: 0, y: 1198, w: 1920, h: 2
geometry: x: 0, y: 0, w: 1920, h: 1200

Expected Results:  
these are the resulting damage events from performing the exact same test in KDE4:

--------- damage event ----------
area:     x: 0, y: 0, w: 1920, h: 1165
geometry: x: 0, y: 0, w: 1920, h: 1200
--------- damage event ----------
area:     x: 70, y: 1166, w: 214, h: 34
geometry: x: 0, y: 0, w: 1920, h: 1200
--------- damage event ----------
area:     x: 0, y: 1165, w: 1920, h: 35
geometry: x: 0, y: 0, w: 1920, h: 1200
--------- damage event ----------
area:     x: 0, y: 0, w: 1920, h: 1165
geometry: x: 0, y: 0, w: 1920, h: 1200

they cover the whole display, which is what I would have expected.

KWin support information:

Version
=======
KWin version: 5.5.4
Qt Version: 5.5.1
Qt compile version: 5.5.1
XCB compile version: 1.11.1

Operation Mode: X11 only

Build Options
=============
KWIN_BUILD_DECORATIONS: yes
KWIN_BUILD_TABBOX: yes
KWIN_BUILD_ACTIVITIES: yes
HAVE_INPUT: yes
HAVE_DRM: yes
HAVE_GBM: yes
HAVE_X11_XCB: yes
HAVE_EPOXY_GLX: yes
HAVE_WAYLAND_EGL: yes

X11
===
Vendor: The X.Org Foundation
Vendor Release: 11803000
Protocol Version/Revision: 11/0
SHAPE: yes; Version: 0x11
RANDR: yes; Version: 0x14
DAMAGE: yes; Version: 0x11
Composite: yes; Version: 0x4
RENDER: yes; Version: 0xb
XFIXES: yes; Version: 0x50
SYNC: yes; Version: 0x31
GLX: yes; Version: 0x0

Decoration
==========
Plugin: org.kde.breeze
Theme: 
Blur: 0
onAllDesktopsAvailable: false
alphaChannelSupported: false
closeOnDoubleClickOnMenu: false
decorationButtonsLeft: 0, 2
decorationButtonsRight: 6, 3, 4, 5
borderSize: 3
gridUnit: 10
font: Noto Sans,10,-1,0,50,0,0,0,0,0
smallSpacing: 2
largeSpacing: 10

Options
=======
focusPolicy: 0
nextFocusPrefersMouse: false
clickRaise: true
autoRaise: false
autoRaiseInterval: 0
delayFocusInterval: 0
shadeHover: false
shadeHoverInterval: 250
separateScreenFocus: false
placement: 4
focusPolicyIsReasonable: true
borderSnapZone: 10
windowSnapZone: 10
centerSnapZone: 0
snapOnlyWhenOverlapping: false
rollOverDesktops: true
focusStealingPreventionLevel: 1
legacyFullscreenSupport: false
operationTitlebarDblClick: 5000
operationMaxButtonLeftClick: 5000
operationMaxButtonMiddleClick: 5015
operationMaxButtonRightClick: 5014
commandActiveTitlebar1: 0
commandActiveTitlebar2: 30
commandActiveTitlebar3: 2
commandInactiveTitlebar1: 4
commandInactiveTitlebar2: 30
commandInactiveTitlebar3: 2
commandWindow1: 7
commandWindow2: 8
commandWindow3: 8
commandWindowWheel: 31
commandAll1: 10
commandAll2: 3
commandAll3: 14
keyCmdAllModKey: 16777251
showGeometryTip: false
condensedTitle: false
electricBorderMaximize: true
electricBorderTiling: true
electricBorderCornerRatio: 0.25
borderlessMaximizedWindows: false
killPingTimeout: 5000
hideUtilityWindowsForInactive: true
inactiveTabsSkipTaskbar: false
autogroupSimilarWindows: false
autogroupInForeground: true
compositingMode: 2
useCompositing: true
compositingInitialized: true
hiddenPreviews: 1
unredirectFullscreen: false
glSmoothScale: 2
colorCorrected: false
xrenderSmoothScale: false
maxFpsInterval: 16666666
refreshRate: 0
vBlankTime: 6000000
glStrictBinding: true
glStrictBindingFollowsDriver: true
glCoreProfile: false
glPreferBufferSwap: 97
glPlatformInterface: 1

Screen Edges
============
desktopSwitching: false
desktopSwitchingMovingClients: false
cursorPushBackDistance: 1x1
timeThreshold: 150
reActivateThreshold: 350
actionTopLeft: 0
actionTop: 0
actionTopRight: 0
actionRight: 0
actionBottomRight: 0
actionBottom: 0
actionBottomLeft: 0
actionLeft: 0

Screens
=======
Multi-Head: no
Active screen follows mouse:  no
Number of Screens: 1

Screen 0:
---------
Name: Mon0
Geometry: 0,0,1920x1200
Refresh Rate: 59.9201


Compositing
===========
Compositing is not active
Comment 1 mcottrell 2016-04-12 15:38:21 UTC
Created attachment 98364 [details]
damage monitoring utility
Comment 2 Thomas Lübking 2016-04-12 15:49:44 UTC
damage notifications ain't the wm's job, but ftr: that would imply that if you activate kwin compositing, the desktop likely won't update anymore either (but only the panel?)

otherwise the bug is rather on your end
Comment 3 mcottrell 2016-04-12 15:58:32 UTC
it's the opposite, everything works fine with compositing enabled. Any hint on which component I should be looking at given it's not the WM? I have tried a bunch of other desktop environments with the same version of X and I'm only seeing this in KDE.
Comment 4 Thomas Lübking 2016-04-12 16:22:24 UTC
the bug is already reassigned to plasmashell.

ftr, this isn't necessarily a bug at all: an exposure will cause a repaint, But that doesn't imply requirement for a damage event. in doubt nothing updated in the desktop window.

however: you do get damage events when you (not so much) expose the desktop in a composited setup??
Comment 5 mcottrell 2016-04-12 17:27:43 UTC
it looks like with compositing enabled any change causes a damage event for the whole screen, which is the same behaviour as KDE4.
Comment 6 Thomas Lübking 2016-04-12 18:28:27 UTC
From the desktop window? You can expect one from the compositor overlay (ie. where it paints everything) since there are visual updates for every minor change of course.


What exactly are you trying to do?
Comment 7 mcottrell 2016-04-12 19:17:41 UTC
from the root window (which I guess is the same as the desktop window?). 

I'm trying to accumulate damaged regions so that I can scrape only pixels that have changed, then encode and transmit them over the network to remote the desktop.
Comment 8 Thomas Lübking 2016-04-12 21:20:12 UTC
(In reply to mcottrell from comment #7)
> from the root window (which I guess is the same as the desktop window?).

Nope. the plasmashell desktop containment is a regular root child (top level window) with special tags to be known as "desktop" - you'll however get every event on the root window if you listen to child events (didn't check your code)

> I'm trying to accumulate damaged regions so that I can scrape only pixels
> that have changed, then encode and transmit them over the network to remote
> the desktop.

Just listen to exposure events in addition - you should not get them while a compositor does the screen and even iff, they'll be part of the damage events from the compositor scene anyway.
Comment 9 mcottrell 2016-04-13 19:59:44 UTC
(In reply to Thomas Lübking from comment #8)
> (In reply to mcottrell from comment #7)
> > from the root window (which I guess is the same as the desktop window?).
> 
> Nope. the plasmashell desktop containment is a regular root child (top level
> window) with special tags to be known as "desktop" - you'll however get
> every event on the root window if you listen to child events (didn't check
> your code)

by listen to child events do you mean setting the event mask for every child window? I tried with xlib and xcb and haven't had any luck finding a way to do this in any other way, but I could be missing something blindingly obvious...

> 
> > I'm trying to accumulate damaged regions so that I can scrape only pixels
> > that have changed, then encode and transmit them over the network to remote
> > the desktop.
> 
> Just listen to exposure events in addition - you should not get them while a
> compositor does the screen and even iff, they'll be part of the damage
> events from the compositor scene anyway.

I ran "xwininfo -tree -root" and tried all of the windows that cover the whole desktop (i.e. window size is 1920x1200):

     0x3600019 (has no name): ()  1920x1200+0+0  +0+0
        1 child:
        0x360001a (has no name): ()  1920x1200+0+0  +0+0
           1 child:
           0x3400013 "Desktop — Plasma": ("plasmashell" "plasmashell")  1920x1200+0+0  +0+0

but when running xev on those windows looking at expose events, I'm seeing nothing when I minimise either a full screen window or a window obscuring part of the desktop. Is the "Desktop — Plasma" window the one you were referring to as the one tagged to be known as "desktop"?

thanks for your replies so far.
Comment 10 Thomas Lübking 2016-04-15 22:55:34 UTC
The X11 server is "unfortunately" pretty much free in deciding when to create expose events (it does so, because it has no data for the window), this could be defeated by a cache (backing store) or bypassing overlay output (not uncommon for GLX)

There's afaik no method to get all frontbuffer updates from the server.
VNC keeps a copy of the framebuffer and compares the pixels of n with n-1 to know which regions to update.

Combining Damage and Un/Map and ConfigureNotify events (alongside a Z test for the latter two) might get you a complete idea on the flattened update region... :-(
Comment 11 mcottrell 2016-04-20 15:39:46 UTC
(In reply to Thomas Lübking from comment #10)
> The X11 server is "unfortunately" pretty much free in deciding when to
> create expose events (it does so, because it has no data for the window),
> this could be defeated by a cache (backing store) or bypassing overlay
> output (not uncommon for GLX)
> 
> There's afaik no method to get all frontbuffer updates from the server.
> VNC keeps a copy of the framebuffer and compares the pixels of n with n-1 to
> know which regions to update.
> 
> Combining Damage and Un/Map and ConfigureNotify events (alongside a Z test
> for the latter two) might get you a complete idea on the flattened update
> region... :-(

I have code to do the n to n-1 comparison, I was using damage events as it seemed like it would be more efficient. Unfortunately it also seems like a less reliable way to keep track of all change. I have stopped using damage events as from what you have said there is no way to guarantee that that they will show all change on a display, and when compositing is active they don't provide much useful information anyway.

I'm not sure what you want to do with this bug. If you feel it's not actually a bug as the desktop is not required to emit damage events when it is exposed (because as you say, it's likely it hasn't actually changed behind the window covering it), then go ahead and close it. I opened it as it was a difference in behaviour from what I have seen in KDE4 and various other desktop environments.
Comment 12 Thomas Lübking 2016-04-20 16:57:37 UTC
I don't maintain plasmashell.
If it's a bug, it's likely upstream (and driven by the GL overlay window nature)