Message Boards Message Boards

1
|
7887 Views
|
9 Replies
|
8 Total Likes
View groups...
Share
Share this post:

Why is web embedded CDF not working?

Posted 10 years ago

I have created and displayed a number of cdf demos on the internet using a remote server. I am having problems with the most recent one. It runs fine within the Mathematica 10 program, but it displays improperly and does not operate on the remote server. The problem can be viewed here:

A dysfunctional demo (Since fixed based on replies.)

I have set the frame dimensions given by the Export dialog in the web page and there is a block of initialization code. The sourcecode is available at the web page. Similar working demos can be accessed here:

examples of working demos

I am hoping that someone will recognize the symptoms and solve the problem. Any ideas?

POSTED BY: Gary Palmer
9 Replies

thereby placing a significant limit on the programs that can be written for CDF?

I don't think it's much of a restriction since one can use Needs[...] in the Initialization option to load any packages that one wishes to use.

Why is that a bad thing? Because it causes repetitions and/or overwriting?

No, mainly because it is a hack (I say this lovingly) and FullDefinition is a function that was introduced in (and I believe not changed since) version 1.0. There is a new undocumented function called Language`ExtendedFullDefinition in version 10 (and perhaps 9?) which is possibly being used now for SaveDefinitions, though I have no real evidence for this.

POSTED BY: David Reiss
Posted 10 years ago

One thing that is worth noting is that any functions or Symbols that one wants to be imported into the Manipulate or DynamicModule using SaveDefinitions must not be Protected (I just was reminded of this by looking though my email archive): this is presumably to keep many packages and contexts that are shipped with Mathematica from being placed in the Initialization option via SaveDefinitions.

thereby placing a significant limit on the programs that can be written for CDF?

It's true though (at least before version 10--I am not sure about any changes in version 10 since I haven't asked recently) that behind the scenes SaveDefinitions is makes use of FullDefinition to get it's information. This may have been upgraded in the recent version of Mathematica....

Why is that a bad thing? Because it causes repetitions and/or overwriting?

POSTED BY: Gary Palmer

When one has relatively little code to include in a Manipulate (or a DynamicModule) it is sensible to place the code directly in an Initialization option. However, once one had more than a modest amount of such code, this approach becomes non-maintainable, so Using SaveDefinitions becomes pretty important. Notwithstanding the dangerous cases that the gurus at StackExchange point out, it is generally safe to use. One thing that they point out, and which is true, is that a saved definition in a Manipulate may overwrite another definition of a function when that Manipulate is displayed on the screen. This also can happen with an Initialization option I believe. One way around this is to create one's Manipulates in a "unique" Context. Some other dangerous issues that are pointed out involve situations that the general user may not easily come by, but it is certainly important to be aware of them. It's kind of like how a physicist uses mathematics. her or she knows about things like uniform convergence of series, but does not worry too much about it in their day-to-day calculations unless a symptom of needing to look into things from this perspective rears its head. Then they take out their quiver of mathematical wisdom and address the issue. That's sort of my way of doing things.

One thing that is worth noting is that any functions or Symbols that one wants to be imported into the Manipulate or DynamicModule using SaveDefinitions must not be Protected (I just was reminded of this by looking though my email archive): this is presumably to keep many packages and contexts that are shipped with Mathematica from being placed in the Initialization option via SaveDefinitions.

It's true though (at least before version 10--I am not sure about any changes in version 10 since I haven't asked recently) that behind the scenes SaveDefinitions is makes use of FullDefinition to get it's information. This may have been upgraded in the recent version of Mathematica....

POSTED BY: David Reiss

It took a little while ;-) but there were some clear symptoms. And, one way to have seen the issue (though I figured it out before this, but I was going to try this next) is that, if you call the manipulate output myManipulate and then execute

InputForm[myManipulate]

you get the following result (in the original problematic case):

Manipulate[If[\[Theta]1 < \[Theta]2, GraphicsRow[{gz, gw[\[Theta]1, \[Theta]2]}, Background -> bgColor, 
   Spacings -> 0, ImageSize -> Large], warning], 
 Style["Choose 1st and last points of domain.\nTry [0, \[Pi]/2] and [\[Pi]/2, 2\[Pi]].", Bold, 
  16], Delimiter, {{\[Theta]1, 0, Style["First", Bold, 12]}, 
  {0, Pi/12, Pi/6, Pi/4, Pi/3, (5*Pi)/12, Pi/2, (7*Pi)/12, (2*Pi)/3, (3*Pi)/4, (5*Pi)/6, 
   (11*Pi)/12, Pi, (13*Pi)/12, (7*Pi)/6, (5*Pi)/4, (4*Pi)/3, (17*Pi)/12, (3*Pi)/2, 
   (19*Pi)/12, (5*Pi)/3, (7*Pi)/4, (11*Pi)/6, (23*Pi)/12, 2*Pi}}, 
 {{\[Theta]2, 2*Pi, Style["Last", Bold, 12]}, {Pi/12, Pi/6, Pi/4, Pi/3, (5*Pi)/12, Pi/2, 
   (7*Pi)/12, (2*Pi)/3, (3*Pi)/4, (5*Pi)/6, (11*Pi)/12, Pi, (13*Pi)/12, (7*Pi)/6, 
   (5*Pi)/4, (4*Pi)/3, (17*Pi)/12, (3*Pi)/2, (19*Pi)/12, (5*Pi)/3, (7*Pi)/4, (11*Pi)/6, 
   (23*Pi)/12, 2*Pi}}, ControlPlacement -> Top, 
 FrameLabel -> Style["Multifunction Domain Selection", 20, Bold], Initialization -> Null]

And there is the smoking gun in the form of Initialization -> Null.

By the way, another way to handle getting this much code into the Manipulate without having to copy it all into the Initialization option, is to have the code external to the Manipulate and then five the Manipulate the SaveDefinitions->True option. This will automatically place the needed definitions into an internal Initialization option.

Finally, you probably want to update the notebook that's on your https://faculty.unlv.edu/gbp/mma/VisualComplexAnalysis/CDF/multifunctionCDF.nb page to the updated Initialization option as a delayed rule.

I''m glad this all worked out! --David

POSTED BY: David Reiss
Posted 10 years ago

call the manipulate output myManipulate and then execute

InputForm[myManipulate]

you get the following result (in the original problematic case):

Manipulate[..., Initialization -> Null]

And there is the smoking gun in the form of Initialization -> Null.

Get the input and look for Null's. Thanks for that useful tip.

In the past, I have had scripts that worked with Initialization but not with SaveDefinitions. I read something on StackExchange that said that SaveDefinitions was unreliable so I haven't used it since.

SaveDefinitions Considered Dangerous search on StackExchange

Finally, you probably want to update the notebook that's on your https://faculty.unlv.edu/gbp/mma/VisualComplexAnalysis/CDF/multifunctionCDF.nb page to the updated Initialization option as a delayed rule.

Thanks for the reminder. Done.

POSTED BY: Gary Palmer
Posted 10 years ago

D. R., what a keen eye to pick out the difference between -> and :> in a hundred lines! But I suppose it has more to do with knowing how things work than with eyesight. Force of habit led me to the ->. I knew it would catch up with me one day. A big up-vote.

POSTED BY: Gary Palmer

J Robinson, CDF is not a server side technology (if you know this already, my apologies). The CDF is downloaded from the server and plays in browser using the CDFPlayer plugin--executing on the local CPU.

POSTED BY: David Reiss

The initialization option should be a delayed rule rather than an immediate rule. I.e., change

Initialization -> (...)

to

Initialization :> (...)

and it then works fine when I deploy it to a CDF and open it in CDFPlayer

POSTED BY: David Reiss
Posted 10 years ago

What OS is on the remote server? Did you check if anti-virus is preventing execute permissions?

POSTED BY: J Robinson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract