Opened 18 months ago

Last modified 3 months ago

#31983 new defect

Safari not showing three.js plots

Reported by: Nathan Dunfield Owned by:
Priority: major Milestone: sage-9.8
Component: graphics Keywords: macOS, Safari, three.js
Cc: Dima Pasechnik, Marc Culler, Paul Masson Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

With Sage 9.3 on macOS Catalina and default browser set to Safari 14.1.1, if I open a Terminal.app window, start sage, and type:

sage: var('x, y')
sage: plot3d(x^2 + y^2, (x, -1, 1), (y, -1, 1)) 

an essentially blank webpage opens in Safari (there is the little "i in a circle" menu in the lower-right corner but no plot).

On the same system, the plot appears fine if I switch to Chrome or Firefox. Moreover, if in Safari I turn on the developer menu, it works ok there as well. Note this is specific to the plots created at the command line; Jupyter notebooks are unaffected.

Based on my testing, I believe that, with the developer menu off, Safari will not pull in script files when they are not located at or below the location of the html file. Specifically, I copied one of the tmp_hash.html files to the attached bad_sage.html and played with different locations and values of the script src for three.min.js. For example, in is current form, if I put a copy of three.min.js in $HOME then Safari opens bad_sage.html when it in $HOME but not if the html file is in $HOME/Desktop or /tmp.

Attachments (3)

bad_sage.html (175.4 KB) - added by Nathan Dunfield 18 months ago.
three.min.js (655.0 KB) - added by Nathan Dunfield 18 months ago.
safari_issue.tar.gz (1.6 KB) - added by Nathan Dunfield 18 months ago.
Minimal nonworking example, three.js free, shows issue with HTML not just JS.

Download all attachments as: .zip

Change History (17)

Changed 18 months ago by Nathan Dunfield

Attachment: bad_sage.html added

Changed 18 months ago by Nathan Dunfield

Attachment: three.min.js added

comment:1 Changed 18 months ago by Dima Pasechnik

Cc: Paul Masson added

comment:2 Changed 18 months ago by Dima Pasechnik

Is this an upstreamable issue?

comment:3 in reply to:  2 ; Changed 18 months ago by Nathan Dunfield

Replying to dimpase:

Is this an upstreamable issue?

Upstream here would be Apple. One could try https://tidbits.com/2020/06/17/how-to-report-bugs-to-apple-so-they-get-fixed/ but quite possibly this is an intensional safety feature, and anyway my impression is that Apple rarely response to bug reports, even from registered Apple developers such as culler.

comment:4 in reply to:  3 ; Changed 18 months ago by Dima Pasechnik

Replying to dunfield:

Replying to dimpase:

Is this an upstreamable issue?

Upstream here would be Apple.

I certainly meant three.js I cannot imagine they can't work around this.

One could try https://tidbits.com/2020/06/17/how-to-report-bugs-to-apple-so-they-get-fixed/ but quite possibly this is an intensional safety feature, and anyway my impression is that Apple rarely response to bug reports, even from registered Apple developers such as culler.

comment:5 in reply to:  4 Changed 18 months ago by Nathan Dunfield

Replying to dimpase:

I certainly meant three.js I cannot imagine they can't work around this.

There is nothing they can do as far as I can see. The problem is that the file three.min.js is not being read by Safari at all because of its location relative to the html file that requests it. This is true of any JavaScript file, nothing specific to three.js.

The obvious if inelegant fix on the Sage side would be to dump all of three.min.js into the (completely temporary) html file in $HOME/.sage/temp/* rather than the current

<script src="$SAGE_LOCAL/share/threejs/build/three.min.js"></script>

line.

Last edited 18 months ago by Nathan Dunfield (previous) (diff)

comment:6 Changed 18 months ago by Dima Pasechnik

If three.js people cannot do anything with it, then this means that by default Safari is not be working with a gazillion other js tools, something I find hard to believe.

comment:7 Changed 18 months ago by Nathan Dunfield

I was able to duplicate the issue without three.js with 1-line .js file and a dozen lines of html, see safari_issue.tar.gz.

As for being hard to believe, note that it only manifests itself when loading local files, something most users never do, and only when they are arranged in a particular way. Moreover, further testing indicates the rule is not:

  • Only load JS files at or below the requesting HTML file.

but

  • Only load JS and HTML files at or below the level of any HTML file previously open in this tab.

This means if a program opens their local HTML docs at the top level, probably the most common reason local files are opened, there will be no issue, even if individual files refer to stuff in directories above them.

Changed 18 months ago by Nathan Dunfield

Attachment: safari_issue.tar.gz added

Minimal nonworking example, three.js free, shows issue with HTML not just JS.

comment:8 Changed 16 months ago by Matthias Köppe

Milestone: sage-9.4sage-9.5

comment:9 Changed 12 months ago by Matthias Köppe

Milestone: sage-9.5sage-9.6

comment:10 Changed 7 months ago by Matthias Köppe

Milestone: sage-9.6sage-9.7

comment:11 Changed 4 months ago by Karl-Dieter Crisman

Confirming original issue. I'm surprised this hasn't come up with the (new) MacOS app, but perhaps those users all (like me) ordinarily have the developer menu on, or only use notebooks?

comment:12 in reply to:  11 ; Changed 4 months ago by Nathan Dunfield

Replying to kcrisman:

Confirming original issue. I'm surprised this hasn't come up with the (new) MacOS app, but perhaps those users all (like me) ordinarily have the developer menu on, or only use notebooks?

Having the developer menu on is surely very uncommon, so it's likely that most use notebooks or have a different default browser (no issue with Chrome or Firefox).

Just to update the ticket, this continues to be a problem with Safari 15.5 on Big Sur (11.6.7).

comment:13 in reply to:  12 Changed 4 months ago by Karl-Dieter Crisman

Having the developer menu on is surely very uncommon, so it's likely that most use notebooks or have a different default browser (no issue with Chrome or Firefox).

Thanks.

Just to update the ticket, this continues to be a problem with Safari 15.5 on Big Sur (11.6.7).

Sorry, I had meant to imply exactly that with my comment:11, but forgot that people can't read my mind.

comment:14 Changed 3 months ago by Matthias Köppe

Milestone: sage-9.7sage-9.8
Note: See TracTickets for help on using tickets.