mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.73k stars 35.38k forks source link

Documentation pages with iframe unreadable on iOS #9195

Closed paulmasson closed 8 years ago

paulmasson commented 8 years ago
Description of the problem

Several documentation pages currently have an iframe used to display the browsers in docs/scenes/ (bones-browser, geometry-browser, material-browser). These pages cannot be read on iOS because the iframe grows continuously.

One fix is to add the iOS workaround from examples/index.html to each of the affected files. I have done this for BoxGeometry as an example, but this is only a partial fix. When viewing documentation pages through docs/index.html, the rotating cube appears when the file is first loaded but does not appear when subsequently selected. This problem after the fix affects Safari desktop and mobile, as well as Firefox mobile, but not Firefox and Chrome desktop. Reloading the page does display the rotating cube again but this is hardly desirable behavior.

Is there a better way to address this issue?

Three.js version
leewz commented 8 years ago

The iframe keeps growing because iOS increases the iframe to fit its contents (including the canvas), and then the frame source resizes the canvas (when animating a frame?) to fit the window, which causes iOS to (...). I suspect that iOS also adds a margin/padding/border to something, which is why resizing the canvas made it a little bigger than the window. If so, removing that would also fix the issue.

Solving it by getting rid of or accounting for the extra pixels, or by position: fixed, means the parent page doesn't need to do anything special. In particular, the parent won't need absolute units to set the child's dimensions.

mrdoob commented 8 years ago

I thought we added a workaround for that already.

https://github.com/mrdoob/three.js/blob/dev/docs/api/geometries/BoxBufferGeometry.html#L21-L31

Is not working anymore?

Maybe the workaround should sit in these files instead?

https://github.com/mrdoob/three.js/blob/dev/docs/scenes/bones-browser.html https://github.com/mrdoob/three.js/blob/dev/docs/scenes/geometry-browser.html https://github.com/mrdoob/three.js/blob/dev/docs/scenes/material-browser.html

paulmasson commented 8 years ago

The fix is working fine. Forgot to close this.

leewz commented 8 years ago

I'm just suggesting a child-side fix, in response to:

Is there a better way to address this issue?

paulmasson commented 8 years ago

@leewz didn't mean to be abrupt with you. We had a fuller discussion in the course of ironing out the details of the related pull request #9196. Hopefully Apple will fix this problem themselves one day.

leewz commented 8 years ago

Don't worry, I'm not bothered.

I checked the other discussion (and linked patches) beforehand to see if it mentioned the cause and if y'all considered a child-side fix.

IMO, the ideal fix would be child-side. The iframe grows infinitely because iOS Safari and the child page disagree on whether the iframe fits its contents. That means, on iOS, the child's resizing somehow makes the contents bigger than the window. That could be a legitimate bug in the child's code, and the parent pays the cost here.

mrdoob commented 8 years ago

IMO, the ideal fix would be child-side. The iframe grows infinitely because iOS Safari and the child page disagree on whether the iframe fits its contents. That means, on iOS, the child's resizing somehow makes the contents bigger than the window. That could be a legitimate bug in the child's code, and the parent pays the cost here.

The solution you're proposing is basically not listening for the resize event in the child. Unfortunately window.innerWidth and window.innerHeight is incorrect when inside an iframe on iOS. This means that, the frame will incorrectly grow at least once.

leewz commented 8 years ago

AFAIK, the iframe only grows if there is a change in size of window content. If there is no JS resize at all, there wouldn't be a first growth.

The solution I use myself is position: absolute, which somehow makes the canvas not count toward the size of the window content.

The potential solutions I have in mind are:

mrdoob commented 8 years ago

These were my findings 2 years ago: https://twitter.com/mrdoob/status/512424678162706432