Bug 171914

Summary: Add heuristic to avoid flattening "fullscreen" iframes
Product: WebKit Reporter: Frédéric Wang (:fredw) <fred.wang>
Component: FramesAssignee: Frédéric Wang (:fredw) <fred.wang>
Status: RESOLVED FIXED    
Severity: Normal CC: ajuma, buildbot, commit-queue, rbyers, rniwa, simon.fraser
Priority: P2    
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 149264, 172107, 173704, 173714    
Attachments:
Description Flags
Patch
none
Patch (use an enum for FrameFlattening)
none
Patch (use an enum for FrameFlattening)
buildbot: commit-queue-
Archive of layout-test-results from ews106 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews103 for mac-elcapitan
none
Archive of layout-test-results from ews115 for mac-elcapitan
none
Archive of layout-test-results from ews123 for ios-simulator-wk2
none
Patch (use an enum for FrameFlattening)
none
Patch (use an enum for FrameFlattening)
none
Patch
none
Patch for landing none

Description Frédéric Wang (:fredw) 2017-05-10 01:36:35 PDT
Some authors implement fullscreen popups as out-of-flow iframes with size set to full viewport (using vw/vh units). We should not flatten such iframes or they could become larger than the viewport. Simon suggested to add it under a preference option (disabled by default for now).
Comment 1 Frédéric Wang (:fredw) 2017-05-10 02:37:07 PDT
Created attachment 309587 [details]
Patch
Comment 2 Frédéric Wang (:fredw) 2017-05-11 02:10:09 PDT
@Simon: I had two questions about this:

1) Maybe (as suggested by Antonio) the settings should be called FrameFlatteningExtraHeuristicsEnabled in case more heuristics are added?

2) Is there a convenient way to enable/disable the option during development? Is it necessary to add it to the context menu of experimental features for that purpose?
Comment 3 Simon Fraser (smfr) 2017-05-11 11:11:56 PDT
(In reply to Frédéric Wang (:fredw) from comment #2)
> @Simon: I had two questions about this:
> 
> 1) Maybe (as suggested by Antonio) the settings should be called
> FrameFlatteningExtraHeuristicsEnabled in case more heuristics are added?

I don't like "FrameFlatteningExtraHeuristicsEnabled" because it doesn't indicate that frames are NOT flattened according to the heuristics.

Maybe we should have:

frameFlatteningEnabled
partialFrameFlatteningEnabled

where frameFlatteningEnabled is the current behavior, and partialFrameFlatteningEnabled is new behavior with heuristics.
frameFlatteningEnabled would trump partialFrameFlatteningEnabled.

> 2) Is there a convenient way to enable/disable the option during
> development? Is it necessary to add it to the context menu of experimental
> features for that purpose?

It would be nice to have this an an Experimental Feature (in the WebKit2 sense, like WebGPU).
Comment 4 Frédéric Wang (:fredw) 2017-05-12 08:41:42 PDT
Created attachment 309897 [details]
Patch (use an enum for FrameFlattening)
Comment 5 Frédéric Wang (:fredw) 2017-05-12 08:46:51 PDT
Created attachment 309898 [details]
Patch (use an enum for FrameFlattening)
Comment 6 Build Bot 2017-05-12 08:48:00 PDT
Attachment 309898 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/API/C/WKAPICast.h:344:  Non-label code inside switch statements should be indented.  [whitespace/indent] [4]
ERROR: Source/WebKit2/UIProcess/API/C/WKAPICast.h:344:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebKit2/UIProcess/API/C/WKAPICast.h:346:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebKit2/UIProcess/API/C/WKAPICast.h:348:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 4 in 59 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Build Bot 2017-05-12 09:43:18 PDT
Comment on attachment 309898 [details]
Patch (use an enum for FrameFlattening)

Attachment 309898 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3726675

New failing tests:
fast/frames/flattening/iframe-flattening-crash.html
Comment 8 Build Bot 2017-05-12 09:43:19 PDT
Created attachment 309904 [details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 9 Build Bot 2017-05-12 09:57:09 PDT
Comment on attachment 309898 [details]
Patch (use an enum for FrameFlattening)

Attachment 309898 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3726732

New failing tests:
platform/mac/fast/frames/flattening/set-preference.html
fast/frames/flattening/iframe-flattening-crash.html
Comment 10 Build Bot 2017-05-12 09:57:10 PDT
Created attachment 309906 [details]
Archive of layout-test-results from ews103 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 11 Build Bot 2017-05-12 10:25:15 PDT
Comment on attachment 309898 [details]
Patch (use an enum for FrameFlattening)

Attachment 309898 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3726786

New failing tests:
platform/mac/fast/frames/flattening/set-preference.html
fast/frames/flattening/iframe-flattening-crash.html
Comment 12 Build Bot 2017-05-12 10:25:17 PDT
Created attachment 309910 [details]
Archive of layout-test-results from ews115 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 13 Build Bot 2017-05-12 10:30:26 PDT
Comment on attachment 309898 [details]
Patch (use an enum for FrameFlattening)

Attachment 309898 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3726797

New failing tests:
fast/frames/flattening/iframe-flattening-crash.html
Comment 14 Build Bot 2017-05-12 10:30:28 PDT
Created attachment 309912 [details]
Archive of layout-test-results from ews123 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 15 Simon Fraser (smfr) 2017-05-12 10:46:05 PDT
Comment on attachment 309898 [details]
Patch (use an enum for FrameFlattening)

View in context: https://bugs.webkit.org/attachment.cgi?id=309898&action=review

> LayoutTests/plugins/frameset-with-plugin-frame.html:6
> +        internals.settings.setFrameFlattening(2); // Full Frame Flattening

Can we put some consts in the IDL, or use an IDL enum?
Comment 16 Frédéric Wang (:fredw) 2017-05-13 10:56:28 PDT
Created attachment 310019 [details]
Patch (use an enum for FrameFlattening)
Comment 17 Frédéric Wang (:fredw) 2017-05-14 03:05:29 PDT
Created attachment 310083 [details]
Patch (use an enum for FrameFlattening)
Comment 18 Frédéric Wang (:fredw) 2017-05-14 23:32:40 PDT
Created attachment 310112 [details]
Patch
Comment 19 Frédéric Wang (:fredw) 2017-05-16 07:18:35 PDT
Comment on attachment 310112 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310112&action=review

> LayoutTests/fast/frames/flattening/iframe-flattening-fullscreen.html:22
> +        test(function() { assert_true(!isUnflatten("iframe2")); }, "iframe with vw/vh units");

note to self: these should probably be assert_false(isUnflatten)
Comment 20 Simon Fraser (smfr) 2017-06-16 13:29:06 PDT
Comment on attachment 310112 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310112&action=review

> Source/WebCore/page/Settings.h:93
> +    FrameFlatteningPartiallyEnabled,

Can we qualify "partially"? What kind of frames still get flattened?

> Source/WebCore/rendering/RenderIFrame.cpp:89
> +            if (style().hasOutOfFlowPosition() && style().hasViewportUnits())
> +                return false;

Maybe move this code into a separate function, since I imagine these heuristics will evolve. The name of the function should reflect the enum value that is currently "FrameFlatteningPartiallyEnabled".

> Source/WebKit/mac/WebView/WebPreferencesPrivate.h:163
> +- (unsigned)frameFlattening;
> +- (void)setFrameFlattening:(unsigned)flag;

unsigned -> WebKitFrameFlattening.

Actually I think you need to leave the existing functions alone, for API compatibility, but still add the new ones.

> Tools/DumpRenderTree/mac/DumpRenderTree.mm:906
> +    [preferences setFrameFlattening:NO];

This should use the enum, not a BOOL.
Comment 21 Frédéric Wang (:fredw) 2017-06-18 23:35:26 PDT
Created attachment 313265 [details]
Patch for landing
Comment 22 WebKit Commit Bot 2017-06-19 00:41:15 PDT
Comment on attachment 313265 [details]
Patch for landing

Clearing flags on attachment: 313265

Committed r218480: <http://trac.webkit.org/changeset/218480>
Comment 23 WebKit Commit Bot 2017-06-19 00:41:17 PDT
All reviewed patches have been landed.  Closing bug.