Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari not showing three.js plots #31983

Open
NathanDunfield opened this issue Jun 15, 2021 · 13 comments
Open

Safari not showing three.js plots #31983

NathanDunfield opened this issue Jun 15, 2021 · 13 comments

Comments

@NathanDunfield
Copy link

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.

CC: @dimpase @culler @paulmasson

Component: graphics

Keywords: macOS, Safari, three.js

Issue created by migration from https://trac.sagemath.org/ticket/31983

@NathanDunfield
Copy link
Author

Attachment: bad_sage.html.gz

@dimpase
Copy link
Member

dimpase commented Jun 15, 2021

comment:1

Attachment: three.min.js.gz

@dimpase
Copy link
Member

dimpase commented Jun 15, 2021

comment:2

Is this an upstreamable issue?

@NathanDunfield
Copy link
Author

comment:3

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.

@dimpase
Copy link
Member

dimpase commented Jun 15, 2021

comment:4

Replying to @NathanDunfield:

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.

@NathanDunfield
Copy link
Author

comment:5

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.

@dimpase
Copy link
Member

dimpase commented Jun 16, 2021

comment:6

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.

@NathanDunfield
Copy link
Author

comment:7

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.

@NathanDunfield
Copy link
Author

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

@mkoeppe
Copy link
Member

mkoeppe commented Aug 22, 2021

comment:8

Attachment: safari_issue.tar.gz

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@kcrisman
Copy link
Member

comment:11

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?

@NathanDunfield
Copy link
Author

comment:12

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).

@kcrisman
Copy link
Member

comment:13

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.

@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants