12
$\begingroup$

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)

$\endgroup$
  • 6
    $\begingroup$ This sort of stuff is infuriating. Creating efficient working layouts in Mathematica is enough to drive you crazy. $\endgroup$ – Mike Honeychurch Oct 9 '14 at 13:35
  • $\begingroup$ Related problem: Resizing or moving Notebook window causes Manipulate to update its argument $\endgroup$ – Kuba Feb 20 '15 at 8:34
  • $\begingroup$ 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? $\endgroup$ – Silvia Sep 23 '15 at 17:52
  • $\begingroup$ @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. $\endgroup$ – Kuba Sep 24 '15 at 6:00
  • $\begingroup$ @Kuba Agree. MMA's dynamic system is too fragile.. $\endgroup$ – Silvia Sep 24 '15 at 6:02
5
$\begingroup$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.