Notebook's position / WindowMargins interfere with Dynamic @ CurrentValue @ WindowSize

Workaround:

Row[{Dynamic[{RandomReal[], cws}, TrackedSymbols :> {}],
  Pane[Invisible[Dynamic[cws = CurrentValue[WindowSize]]], ImageSize -> {0, 0}]}]

though maybe include cws in TrackedSymbols.

Edit by OP:

Here is the same idea implemented in a more idiomatic manner:

DynamicModule[{cws}
, DynamicWrapper[
    Dynamic[{RandomReal[], cws}]
  , FEPrivate`Set[cws, CurrentValue[WindowSize]]
  ]
]

Dynamic is triggered only when cws changes as opposed to having assigned (the same) value.

Additionally FEPrivate`Set and making cws a DynamicModule variable, allows us to do this part completely FronEnd side. We didn't get rid of original spam but now it does not need to waste time and links by going to kernel and back, only the main Dynamic content will need to go there.

This can be confirmed using LinkSnooper.


I'm not sure this counts as an answer; perhaps it just casts more darkness on the issue.

First your example can be reduced to

Dynamic[{RandomReal[], CurrentValue[WindowSize]}]

Second and perhaps even more annoying is

DynamicModule[{n = 0},
  Dynamic[{n++, CurrentValue[WindowSize]}, TrackedSymbols :> {}]]

which updates n when the window is moved.

My take on this is that the front-end is getting events from the OS whenever you move the window, and these events (which are probably something like or equivalent to {{left, top}, {right, bottom}} in screen coordinates) cause the front-end to recompute WindowSize for each event instance. Further, it would seem that can't be turned off by the user with TrackedSymbols :> {}, so any expression wrapped with Dynamic containing WindowSize is going to be evaluated as the window moves.