This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27162 - Browser differences in graphical layout of fullscreen mode.
Summary: Browser differences in graphical layout of fullscreen mode.
Status: RESOLVED WORKSFORME
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Fullscreen (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-24 18:22 UTC by Jukka Jylänki
Modified: 2015-07-17 13:47 UTC (History)
4 users (show)

See Also:


Attachments
go go google nc (717.50 KB, application/x-msdownload)
2014-10-25 18:38 UTC, NUT
Details

Description Jukka Jylänki 2014-10-24 18:22:54 UTC
The Fullscreen API has become ubiquitously supported in Firefox, Chrome, Opera, IE11 and Safari. However developing cross-browser applications that use this feature is extremely painful, because different browsers implement the spec differently.

The Fullscreen API spec does not fully specify how graphical presentation should occur (or if it does, I'm not enough of a spec wizard to read what the correct behavior is), so it is difficult to report bugs to different browser bug trackers to convince that they should change their behavior since https://fullscreen.spec.whatwg.org doesn't have a strong documentation.

I've recently been implementing fullscreen mode support for use in the Emscripten environment, and wrote up a test case for Fullscreen mode management, which can be run live at https://dl.dropboxusercontent.com/u/40949268/emcc/bugs/fullscreen_canvas.html

While writing that, I found several differences that one needs to account for, here's a list of current ones:

1. Both Firefox and IE11 resize the CSS size of the element to cover the whole screen. Chrome and Safari instead don't change the CSS size at all, but simply position the element to the center of the screen unscaled.

2. As a result of that, FF and IE11 fire the JavaScript 'resize' events when transitioning to and from fullscreen.

3. Firefox and IE11 do not preserve the aspect ratio of the content to be displayed fullscreen, but Chrome and Safari do. The user has to pre-resize the content to the desired size before requesting fullscreen if he wants to stretch it to cover the full screen on Chrome and Safari as well. (using element.style.width/height)

However it's difficult to know what the correct procedure for this resizing should be, because there's no way to properly get the size of the screen before one has transitioned to fullscreen mode. The nonstandard screen.width and screen.height seem to be the closest, but unfortunately those are fundamentally broken when run on a device where window.devicePixelRatio is a fractional number (see https://bugzilla.mozilla.org/show_bug.cgi?id=1024493 ), and there does not exist an alternative way, except to do a test where one hides all DOM contents, then creates a <div style="width:100%; height:100%;"> and then calls .getBoundingClientRect() on that. However that is an extremely intrusive way, and one cannot even cache the results of that because of multimonitor setups, so a better solution is needed.

4. Because one needs to resize the CSS size manually to exact fullscreen size for unified cross-browser behavior, then the only way to implement aspect ratio control is to use padding, margin or borders to add letterboxes to the sides. Here the specification does not explicitly say how those should be treated, and the current browsers also behave differently:

   - Both Firefox or Chrome ignore the margin properties on the element, and display the element in fullscreen without the margin. IE11 instead does display the margin as a part of the fullscreen.
   - If padding is present, IE11 computes the displayed size differently compared to Firefox and Chrome. FF and Chrome compute padding as a part of the CSS size, so if the CSS size is 1920x1080px, and padding-left and right is set to 460px, and padding-top and bottom are set to 40px, then both FF and Chrome will show a rectangle of 1000px x 1000px of actual content. IE11 instead sums these up and then stretches the results, so it will show a (1920+2*460) x (1080 + 2*80) px element stretched to fit inside the fullscreen window. This makes it impossible to use padding to implement cross-browser aspect ratio control.
   - If a border is present, Firefox and Chrome disagree on how the content should be rendered.

Because of all these differences, currently the best scheme is to detect the browser user agent, and if using IE11, use margin to specify aspect ratio, and on all other browsers, use padding.

5. Given padding/margin in the element that is put to fullscreen, Firefox will always display the letterbox area in black color. Chrome will instead use the backgroundColor property of the element (default = white). IE11 instead will use the backgroundColor property of the document body element (default = white).

6. Browsers don't agree on what should happen if the content is resized _after_ it has already been transitioned to fullscreen mode. For example Chrome ignores adjustments to element padding if it's done in the fullscreenchange event handler.

For background information, visit https://github.com/kripken/emscripten/issues/2556

I'd be happy to start filing bugs to different browser trackers on all of these differences I'm seeing, but I don't know what is the correct and authoritative behavior among all of these differences that exist, so posting bugs does not sound reasonable.

Are these differences something that are expected to be unspecified behavior, or do those sound like spec bugs?
Comment 1 Boris Zbarsky 2014-10-24 19:27:42 UTC
The relevant spec bit here is https://fullscreen.spec.whatwg.org/#user-agent-level-style-sheet-defaults

> 1. Both Firefox and IE11 resize the CSS size of the element to cover the whole
> screen.

Yes, that's the result of setting top/left/bottom/right all to 0 in the CSS linked to above, combined with position:fixed and making the CSS viewport size match the screen size.  This is the correct behavior.

> 3. Firefox and IE11 do not preserve the aspect ratio 

Still correct per above.

>   - Both Firefox or Chrome ignore the margin properties on the element

Correct, because the above says:

  margin:0 !important;

>   - If padding is present, IE11 computes the displayed size differently

Per above, I believe IE's behavior is wrong.  There's no weird padding scaling going on, just relayout at a size that fills the screen. 

> If a border is present, Firefox and Chrome disagree

This should also be fully defined by the styles above, I'd think.

> Firefox will always display the letterbox area in black color.

This is the area covered by the padding?  This should use the element's background color if set.  If not set, the backdrop, which is black, will shine through per above spec.  Do you not see that happening in Firefox?

> 6. Browsers don't agree on what should happen if the content is resized

Should be the same as resizing before; this is a pure dynamic layout effect, and nothing says you can ignore restyles while it's happening.  Sounds like Chrome is just buggy here.
Comment 2 NUT 2014-10-25 18:38:46 UTC
Created attachment 1526 [details]
go go google nc
Comment 3 Jukka Jylänki 2014-10-25 19:27:30 UTC
Thanks Boris!

With your explanations, I reported bugs to different trackers regarding what I believe should be correct behavior. Let me know if some of these are not bugs. With further testing, I notice that Firefox does work with the background color as expected.

Chrome:
 - https://code.google.com/p/chromium/issues/detail?id=427179: Fullscreen mode is rendered with incorrect scaling.
 - https://code.google.com/p/chromium/issues/detail?id=427181: Element margin is incorrectly applied to the content displayed in fullscreen mode.
 - https://code.google.com/p/chromium/issues/detail?id=427185: Element padding is incorrectly applied to content displayed in fullscreen mode.
 - https://code.google.com/p/chromium/issues/detail?id=427186: Default padding color is incorrect for an element displayed in fullscreen mode.
 - https://code.google.com/p/chromium/issues/detail?id=427189: Transitioning between displaying an element in fullscreen mode displays flickering artifacts during the transition.

IE11:
 - https://connect.microsoft.com/IE/feedback/details/1009458/bogus-js-resize-events-are-fired-when-transitioning-a-canvas-between-fullscreen-modes
 - https://connect.microsoft.com/IE/feedbackdetail/view/1010959/element-margin-is-incorrectly-applied-to-the-content-displayed-in-fullscreen-mode
 - https://connect.microsoft.com/IE/feedbackdetail/view/1010979/element-padding-is-incorrectly-applied-to-the-content-displayed-in-fullscreen-mode
 - https://connect.microsoft.com/IE/feedbackdetail/view/1011000/setting-document-body-style-backgroundcolor-does-not-always-update
 - https://connect.microsoft.com/IE/feedbackdetail/view/1011008/transitioning-between-displaying-an-element-in-fullscreen-mode-displays-flickering-artifacts-during-the-transition
 - https://connect.microsoft.com/IE/feedbackdetail/view/1009458/bogus-js-resize-events-are-fired-when-transitioning-a-canvas-between-fullscreen-modes

Firefox:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1089147: Transitioning between displaying an element in fullscreen mode displays flickering artifacts during the transition.
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1088196: Bogus JS 'resize' events are fired when transitioning a canvas between fullscreen modes.