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

Cocoa WebView rendering / interactivity issues (video/audio), setWantsLayer vs. CSS 3D trick #21

Closed
danielweck opened this issue Oct 21, 2014 · 6 comments

Comments

@danielweck
Copy link
Member

Fixed layout issue only.

  1. Problem: without Cocoa-NSView-setWantsLayer and CSS-3D (-webkit-transform: translateZ(0)), OSX-WebView renders the iframe contents partially (top-left corner only, rectangular surface area equivalent to the percentage of the transform-scale applied to the "scaler" div (iframe parent element)). The HTML inspector reveals that the content actually exists (text can be selected with the mouse, etc.), but somehow it does not get composited by the WebView / Cocoa rendering pipeline.

  2. With setWantsLayer applied to the NSView control (either the WebView itself, or its superview), there are some improvements but not across the board (i.e. not with every FXL titles) For example, highly-graphical content that makes use of CSS animations (sprites, etc.) fails to render correctly. Sometimes, pages are blank (white empty background), yet the HTML/CSS inspector shows that the tree is rendered correctly in the backstore, just not flushed correctly in the display layer.

  3. With CSS-3D applied to the iframe or its parent element, there are no display issues (i.e. no "invisible" or cropped content), but unfortunately there are nasty side effects, such as broken HTML5 audio/video interactivity, lack of text selection, jagged font rendering.

@danielweck
Copy link
Member Author

See: 71fb04c

@danielweck
Copy link
Member Author

(note: above description updated)
Possible alternative solution: complete re-think of the FXL view architecture (which is implemented in readium-shared-js), migrate away from HTML iframe towards native WebViews (one for each EPUB HTML/SVG content document). This major application-specific refactoring would be costly to design, implement and test. Readium's document loading infrastructure and feature-injection mechanism depend on the known behaviours of HTML iframe (security, cross-origin communication), so this would unfortunately not be just a straight swap from iframe to WebView (this would include replacing the reader.html top-level wrapper by a Cocoa NSView hierarchy). This would require a lot of native ObjectiveC code to replicate the layout routines that fixed_view.js and one_page_view.js currently implement, and an entirely new bridge API between the reader.js, annotations.js, media_overlays.js (etc.) who would need to access the DOM hosted in the native WebViews.

danielweck added a commit to readium/readium-shared-js that referenced this issue Oct 22, 2014
…s a workaround for the fixed layout scaled rendering (CSS transform), see readium/SDKLauncher-OSX#21
danielweck added a commit that referenced this issue Oct 22, 2014
@danielweck
Copy link
Member Author

Ah, I figured-out a pure-CSS trick to work around the WebView rendering / clipping bug. Basically, the scaling mechanism for fixed-layout documents has to apply to the HTML document itself, so that its full composited surface area is picked-up by Cocoa / NSView.

Because this is a CSS transform, it does not affect the computed CSS dimensions of wrapper div and iframe, so it works just as in the normal case (no side effects / regression bugs in coordinate /size computations, and the visual result is the same). Caveat: authored HTML documents may originally contain a CSS transform on the root html element, in which case it gets overridden by Readium's own (but, because this edge-case is unlikely to occur, I think it is a perfectly acceptable trade-off).

See: readium/readium-shared-js@ca4e1d0 and e909269#diff-2

@danielweck
Copy link
Member Author

Although the fix referred-to above works fine for general rendering (including rich CSS animations), there may still be occasional issues with audio/video. See #22

@rkwright
Copy link
Contributor

I just tested with my SmokeTest files and it looks good. Will also run through the relevant EPUB Test Suite files next.

@danielweck
Copy link
Member Author

Thanks @rkwright If you have observations about video/audio and non-selectable text, feel free to populate the discussion in this issue: #22 (I usually manage to "restore" normal behaviour by resizing the viewport...but may you'll have a different experience)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants