# Notebook's WindowSize interference with contents' Dynamic ImageSizes

Bug introduced in 8 or earlier and persists through 11.3

Consider the following MWE:

CreateDocument[
DynamicModule[{x = {500, 500}},
Framed[
"test"
, ImageSize -> Dynamic[Print[RandomReal[]]; x, TrackedSymbols :> {x}]
]
]]


The resulting notebook prints streams of numbers when you are changing it's window size. It is not expected since x is not connected to "WindowSize" option or CurrentValue.

If you nest more such Frames you can see ugly effect of notebook scrollbars position delay in reference to notebook frame.

Confirmed bug. Can't be fixed in 10.0.2 so we have to wait for next release. (\$WolframNext)

• This sort of stuff is infuriating. Creating efficient working layouts in Mathematica is enough to drive you crazy. – Mike Honeychurch Oct 9 '14 at 13:35
• – Kuba Feb 20 '15 at 8:34
• Could it be possible that the resizing forced redrawing on the FrontEnd side, thus forced a evaluation of the Dynamic code regardless it's changed or not? – Silvia Sep 23 '15 at 17:52
• @Silvia That sounds like the explanation that I could live with but I it is not supposed to happen. At least this is what J. Fultz has said on WTC last autumn when I had asked him but that. – Kuba Sep 24 '15 at 6:00
• @Kuba Agree. MMA's dynamic system is too fragile.. – Silvia Sep 24 '15 at 6:02

I also consider this an unacceptable bug. Nevertheless I wanted to share a workaround which I think avoids the problem but is unfortunately a lot of effort to add to more complicated cases:

CreateDocument[
DynamicModule[{x={500,500},lastValue},
Framed[
Slider[Dynamic[x[[1]]],{400,600}],
ImageSize->Dynamic[
If[x=!=lastValue,lastValue=x;Print[RandomReal[]];x,x],
TrackedSymbols:>{x}
]
]
]
]


Note: my originial answer did actually answer a different question, the code shown here is an adapted version of the workaround provided by Kuba.

• Yes ;) I did this because sometimes people don't go below first answer. Now everything what's important is scanned in a glimpse ;) – Kuba Feb 20 '15 at 8:39