-
Notifications
You must be signed in to change notification settings - Fork 64
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
IFrame scope issues in 0.6.0 #225
Comments
I've been looking at this for... a while. I think the issue boils down to this line in p5: // this is the p5 instance
this._setup = function() {
// ...
var canvases = document.getElementsByTagName('canvas');
for (var i = 0; i < canvases.length; i++) {
// unhide canvases
}
} P5 hides canvases when they're created (to avoid a "flicker" while they're being setup) and then unhides them after the setup is done. However, (and I'm about 90% sure of this), document in this context refers to the document of the parent window and not the document of the IFrame. The reason for this is because p5 is loaded in the top window context (since that's where WebIO is loaded and that's where SystemJS "lives"). To be more explicit, in a Jupyter notebook,
I'm not 100% sure that this is fixable in general. If P5 will take the merge request, it can be fixed by doing The reason I don't think it's fixable in general (i.e. wherever this issue with |
Thanks for looking into this 🙂 I agree with your analysis (at least as far as I understand any of this), and I agree that the central problem is that However, I should mention that my actual goal is not to make this p5.js demo work (it was just an existing example that broke at some point and made for an easy MWE of the problem). My actual goal is to get https://github.com/rdeits/MeshCat.jl working properly again in Jupyter with WebIO. The MeshCat javascript code is pretty particular about its styling, so the only way I've been able to get it to reliably render well is to use an iframe to separate it from Jupyter and its CSS. That said, I suspect I can edit it to work in a context in which |
Hmmm, well if it's strictly a CSS issue, there are some "fixes" to remove Jupyter-specific styling that you could try: https://stackoverflow.com/questions/10064172/how-to-isolate-a-div-from-public-css-styles. |
I think one possible solution would be to have the IFrame load the generic HTTP provider bundle with a shim. That could be feasible but it definitely a very heavyweight solution; if at all possible, IFrames should be avoided, especially if there will be several. But at the very least, this might be fixable to work as it did before. |
Hi all! I'm having some issues with MeshCat.jl using WebIO 0.6.0, and I think the problem comes down to the new iframe behavior. As an example, try running the p5.js demo in IJulia, using an iframe to wrap its output:
I see no output at all from this when using WebIO 0.6.0. From poking around at the similar issues with MeshCat.jl, I think the problem is that previously we were running JS code inside the iframe's scope (with
window
anddocument
set to those of the iframe), but that no longer seems to be the case.The text was updated successfully, but these errors were encountered: