Edit: This is a rewrite. The original answer was more or less an extended comment containing some seemingly relevant clues. I've tracked down two probable issues, each related to a system variable, and there may be others. At least in either case, the crashing can be triggered or prevented.* It turns out that Dynamic@RegionPlot[..]
depends on the variables $PlotTheme
and $DisplayFunction
and that evaluating ContourPlot
triggers an update. Beyond this, I'm not sure how the crash occurs. The evaluation of ContourPlot
triggers an update of RegionPlot
. This apparently occurs simultaneously, the ContourPlot
being requested via the main link and the RegionPlot
via the preemptive link. It would not be surprising if one interferes with the other and leads to the crash.
The following shows ContourPlot
tickles $PlotTheme
and $DisplayFunction
. Evaluate ContourPlot
repeatedly and see pt
and df
be incremented.
pt = 0; df = 0;
Dynamic[{++pt, $PlotTheme}, TrackedSymbols :> {$PlotTheme}]
Dynamic[{++df, $DisplayFunction}, TrackedSymbols :> {$DisplayFunction}]
(* new cell *)
ContourPlot[x + y, {x, -2, 2}, {y, -2, 2}]
The following shows that Dynamic@RegionPlot
depends on $PlotTheme
and $DisplayFunction
. Evaluate the plot and then evaluate the others in turn and see the RegionPlot
be updated.
Dynamic[RegionPlot[x^2 + y^2 < 1, {x, -2, 2}, {y, -2, 2}]]
$DisplayFunction = Hold
$DisplayFunction = Identity
$PlotTheme = "Web"
$PlotTheme = Automatic
Here is a simple workaround: add TrackedSymbols :> {pts}
. Below you can uncomment the other symbols, if you wish to observe the kernel crashing. (It seems to be a race situation. It doesn't always crash when you evaluate the ContourPlot
, but it usually does. It crashes if you uncomment one, the other, or both symbols.)
LocatorPane[Dynamic[pts],
Dynamic[Show[
Graphics[{Arrow /@ Partition[pts, 2]}], {a1, b1} =
Transpose[Map[Module[{p1, p2, d}, {p1, p2} = #;
d = p2 - p1;
{d, p1.d}] &, Partition[pts, 2]]];
RegionPlot[
And @@ Thread[a1.{x1, y1} < b1], {x1, -2, 2}, {y1, -2, 2}]],
TrackedSymbols :> {pts(*, $PlotTheme*)(*, $DisplayFunction*)}]]
Acknowledgement: Karsten 7.'s observation about SynchronousUpdating -> False
led me to observe that evaluating ContourPlot
causes the dynamic RegionPlot
to be reevaluated. Further investigation led me as far as $PlotTheme
and $DisplayFunction
.
crash
tag; in addition to categorization it helps to warn people who blindly execute Question code. :-) $\endgroup$ContourPlot
in a separate cell, it does not crash. Reminds me of my experience with this question, which seems to have nothing to do withDynamic
. $\endgroup$Dynamic@Refresh[ContourPlot[...], None]
does not crash. $\endgroup$