0
$\begingroup$

Correction
The issue described below it is not caused by CDF Player Pro after all. Apologies for the confusion. The Dynamic loop just unexpectedly stops anyways (it just takes longer when run in Mathematica rather than in Player Pro). Question title should be modified to: "Dynamic loop unexpectedly stops".
(sorry I do not know how to do that)

Content:
- The issue
- Details

The issue
I have created a dynamic loop in Mathematica V11.1. When I run the notebook or CDF document, said loop unexpectedly stops. I simplified the original code by reducing it to a trivial loop (please see below) ... there must be some incorrect logic implemented there.

Details
I found that the time taken for the below mentioned loop to stop is not constant.
Example (approx values in seconds):
run in M V11.1.1 --> {5, 5032, 1060, 446, 2530, 2416}
run in CDF Player Pro --> {249, 222, 292, 2011, 1370}

No error message is returned, I also did not notice any "anomalies" in "Windows Event Viewer".

Once the loop stops I re-launch it following these steps:
- Disable Dynamic Update
- Quit Local Kernel
- Evaluate Notebook
- Enable Dynamic Update

I also tried (without success) the following:
- running the loop from within a package that I created
- wrapping the dynamic loop around Manipulate

What did I do wrong? Does anyone have any suggestion on how to solve this issue?
Thanks again.

Framed[
DynamicModule[
{samplingPeriod = 5, process, output, adesso, timeInit, timeInitRel,
deltaT, deltaTRel, draw, count = 0},
Column[{
 (*--- Outer time loop ---*)
 Dynamic[
     count++;
     deltaT = DateDifference[DateObject[timeInit], DateObject[Now],"Second"];
     deltaTRel = Quantity[count, "Second"];
     Grid[{{"Time", "Abs Duration", "Rel Duration"}, {DateString[Now],
     deltaT, deltaTRel}}]
 , UpdateInterval -> 1, SynchronousUpdating -> True, 
 TrackedSymbols -> {}]
,
(*--- Computational loop ---*)
Dynamic[
 (*--- Simple process ---*)
 draw = RandomReal[];
 (*-- Time stamp of the simple process ---*)
 adesso = DateString[Now];

 output = Column[{
    Row[{"Last Sampling time: ", adesso}],
    Row[{"Draw: ", draw}]
    }];
 Panel[output]
 , UpdateInterval -> samplingPeriod, SynchronousUpdating -> False,
  TrackedSymbols -> {}]
}],
Initialization :> (
(*--- Initate time loop ---*)
timeInit = Now;
)]]
$\endgroup$
  • $\begingroup$ This is probably better suited for Wolfram's support $\endgroup$ – user6014 Sep 24 '18 at 17:18
  • $\begingroup$ I actually did contact Wolfram's support. They are not aware of such issue. They said most probably it is due to the OS. But I am in no position to test in multiple machines/OS CDF-Player Pro. Hence my post. $\endgroup$ – Guaro Sep 25 '18 at 1:14
  • $\begingroup$ They didn't investigate to help you figure out the issue? Did they look at your code? $\endgroup$ – user6014 Sep 25 '18 at 1:15
  • $\begingroup$ Not sure if they did. My email did contain the code (very similar to the one I posted) ... but that was it. No suggestions on how to solve this issue. $\endgroup$ – Guaro Sep 25 '18 at 1:19
  • 1
    $\begingroup$ One more thing: While it is an interesting thing to play with I don't think that using the Dynamic functionality as a way to control program execution as in your example is such a good idea. The problem is that the update mechanism for Dynamics is difficult to control, e.g. when a Dynamic is not shown, it will not update. I think it probably would be better to do the actual computations with a ScheduledTask and only use Dynamic to display the results. I even would think that the problems you see might somehow be related to this use of Dynamic... $\endgroup$ – Albert Retey Sep 26 '18 at 7:50

Your Answer

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

Browse other questions tagged or ask your own question.