3
$\begingroup$

Consider the following Manipulate:

Manipulate[Plot3D[Sin[x] Cos[y], {x, 1, 5 a}, {y, 1, 5 a}], {a, 1, 5}]  

When trying to step forward clicking the line of the slider, the plot will render fairly quickly. However using the animation control: + button or – button, the rendering process takes several seconds, sometimes up to eight seconds.

As seen below, the 3D-plot is not rendered approx. 3 seconds after pressing the + button.

enter image description here

Below, the slider has been pressed followed by an almost instant rendering.

enter image description here

This may seem like an insignificant phenomenon but the reason for this difference in speed isn't clear to me.

Any suggestions as to why this is and how the delay can be avoided?

$\endgroup$
4
$\begingroup$

It is as if the Animator is waiting 3 sec. to see if you are going to make further clicks, before triggering the final ($ControlActiveSetting == False) update. Indeed, one can see that there is a delay after hitting the plus button (or minus button), before ControlActiveSetting is changed from True to False; almost immediately after the setting changes, the plot is updated.

Manipulate[{Dynamic[$ControlActiveSetting], 
  Plot3D[Sin[x] Cos[y], {x, 1, 5 a}, {y, 1, 5 a}]}, {a, 1, 5}]

This can be confirmed with LinkSnooper as well. I could find no $FrontEnd options or SystemOptions that might control this delay.

My guess is that the delay allows the user to adjust several controls before a high-quality update is triggered. Since these might take a long time, I assume Wolfram thought that a three-second (or whatever) delay is an appropriate compromise.

Update: Addendum

I probably should have pointed out, especially since it is not often mentioned, that by default, plots depend on $ControlActiveSetting because the default option setting PerformanceGoal -> $PerformanceGoal has the value

OwnValues[$PerformanceGoal]
(*
  {HoldPattern[$PerformanceGoal] :> 
    If[$ControlActiveSetting, "Speed", "Quality"]}
*)

Anyone using Manipulate with plots will be familiar with the effect. This and the system setting $ControlActiveSetting to True when a control is operated are the causes.

$\endgroup$
3
$\begingroup$

In light of Michael's revelation the only solution I can think of is to make the early rendering higher quality as described in PolarPlot render oddities. If the higher quality version renders faster than the delay to $ControlActiveSetting this will result in faster updating.

Manipulate[
 Plot3D[Sin[x] Cos[y], {x, 1, 5 a}, {y, 1, 5 a}, 
   PerformanceGoal -> "Quality"],
 {a, 1, 5}
]
$\endgroup$
  • 1
    $\begingroup$ @MathLind This is a good answer, which I upvoted, and while it alludes to a partial reason given in the linked question, it primarily gives a workaround. But the Question asks "Why?", not "How?" You could consider changing your question to clarify the relationship between Q and accepted A. (Since your example came straight from the docs, I thought you were genuinely interested only in the Why question, which I also found much more interesting than how to avoid it, even if my findings ran into a wall that probably only WRI can see behind. The How question has been asked before in several ways.) $\endgroup$ – Michael E2 Feb 1 '15 at 14:08
  • $\begingroup$ @MichaelE2 Thank you for clarification which makes a lot of sense. Honestly in my head, I intended to ask both Why and How. I will edit my question accordingly. BTW, what is the meaning of "straight from the docs" ? $\endgroup$ – MathLind Feb 1 '15 at 14:14
  • $\begingroup$ @MathLind I may be misremembering...I thought the plot of Sin[x] Cos[y] is an example actually in the documentation. $\endgroup$ – Michael E2 Feb 1 '15 at 14:17
  • $\begingroup$ @MichaelE2, I don´t know. I will have to check it. Thanks anyway. $\endgroup$ – MathLind Feb 1 '15 at 14:18
  • $\begingroup$ @MathLind As always what you do with the Accept is entirely your prerogative, but I would support your switching the Accept to Michael's answer. I really intended mine to complement his, not supplant it. $\endgroup$ – Mr.Wizard Feb 1 '15 at 14:21
2
$\begingroup$

In Version 9, the option settings ContinuousAction->True for Manipulate combined with PerformanceGoal -> "Quality" for Plot seems to eliminate the delay.

Using @Michael E2's example:

Manipulate[{Dynamic@$ControlActiveSetting, 
  Plot3D[Sin[x] Cos[y], {x, 1, 5 a}, {y, 1, 5 a}, PerformanceGoal -> "Quality"]}, 
  {a, 1, 5}, ContinuousAction -> True]

enter image description here

$\endgroup$
  • $\begingroup$ It works the same in V10, too. However, I don't see any difference in behavior of either $ControlActiveSetting or the plot if I omit ContinuousAction -> True (Mr. Wizard's solution). It seems to me the principal change is that the plot no longer depends on $ControlActiveSetting because of the setting of PerformanceGoal. $\endgroup$ – Michael E2 Feb 1 '15 at 12:53

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.