Closed Bug 1935189 Opened 2 months ago Closed 15 days ago

`container-type: inline-size` in outer document prevents resize events from firing when iframe changes from `display:none` to `display:block`

Categories

(Core :: Layout, defect)

defect

Tracking

()

VERIFIED FIXED
136 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 --- wontfix
firefox133 --- wontfix
firefox134 --- wontfix
firefox135 --- wontfix
firefox136 --- verified

People

(Reporter: dholbert, Assigned: emilio)

References

(Blocks 2 open bugs, Regression)

Details

(Keywords: regression, webcompat:platform-bug)

Attachments

(7 files)

STR:

  1. Load testcase.
  2. Open your Web Console (F12) (optional)
  3. Click the "Click" button in the testcase.

EXPECTED RESULTS:

  • The iframe should appear with "Resize count: 1".
  • console.log should show "IFRAME RESIZED" when you click the button.

ACTUAL RESULTS:
The iframe appears with "Resize count: 0"

Attached file testcase 1

emilio: hoping you can take a look, as this seems to be a container-queries issue (that being the only difference between the testcase & reference case).

Flags: needinfo?(emilio)

Here's a somewhat more reduced/standalone testcase.

Attached file reference case 2
Assignee: nobody → emilio

I just noticed in bug 1933229 that this reproduces even if the container-type element isn't an ancestor of the iframe. Here's a testcase to demonstrate that.

(It doesn't matter whether the element comes before or after in the DOM.)

As noted in bug 1933229 comment 8: this is a regression from when we enabled container queries (because the bug is specific to container-type: inline-size). That happened in this Nightly range:
Last good: 2022-11-20
First bad: 2022-11-21
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=d2c6287383301f29964047d5c718640eb4bbcccb&tochange=a29b80b107103df84e493008e420e30aea857da1

In builds from shortly after that time period, you can avoid the bug by toggling layout.css.container-queries.enabled to false (just as the reference cases here avoid the bug by removing the container-type styling).

This is rather tricky / unfortunate, but this is the low-risk fix for
now. The issue is as follows:

When we construct a subdocument frame, we try to show its viewer by
using a script runner which will call ShowViewer().

If ShowViewer() gets called before the subdoc frame gets laid out
(has the NS_FRAME_FIRST_REFLOW bit set), we pick an (arbitrary) 10x10
device pixel size, and initialize the page with that viewport.

Then, eventually, the frame gets laid out to the correct size and fires
a resize event.

If we have container queries around, we need to lay out the page while
styling, which causes the layout to happen before the script blocker
checkpoint, and thus the viewport to get initialized with the right size
to begin with.

This generally shouldn't be bad, but pages google chat seems to rely on
this resize event (and the divergence being caused by container queries
is rather unfortunate).

For now, do the low risk fix of always using the "initial" subdoc frame
size to show the viewer.

We should ideally sort this out better. Even our "good" behavior is
quite bizarre (e.g, I'd expect going from display: block to none to
trigger a resize event and the viewport to go back to 0... As you noted,
chrome's inner layout sizes do change when the frame is display: none).

But it seems worth to land this at least in the interim.

Sorry for the lag, see the commit message for diagnostic and details... This seems all rather messy, but for now I restored our no-container-query behavior...

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0c612ed5d669 Don't make frame initial viewport size depend on whether it's been laid out. r=dholbert
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/49955 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 15 days ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
Upstream PR merged by moz-wptsync-bot

The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox135 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

I think given Google has a workaround and this is a rather subtle area, we can let this ride the trains, but let me know if you disagree.

Flags: needinfo?(emilio) → needinfo?(dholbert)

Yup, agreed.

Flags: needinfo?(dholbert)

I just verified that this is fixed in Nightly 136.0a1 (2025-01-08) using the attached testcases, too. --> updating status.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: