Open Bug 1661544 Opened 4 years ago Updated 16 days ago

innerWidth on android without <meta name=viewport> doesn't return the proper value if you query it early enough

Categories

(Core :: Layout, defect)

defect

Tracking

()

People

(Reporter: emilio, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

If you load https://crisal.io/tmp/screen-desktop-viewport.html on Android nightly, you get something like:

innerWidth: 414
innerHeight: 802
outerWidth: 411
outerHeight: 797
screen.width: 414
screen.height: 874 

You get different results if you dump the values after load, with innerWidth=980, which is the right viewport value because this page has no <meta viewport> all along.

I think this is because we haven't sized the layout viewport yet by the time this happens. But Chrome and Safari do manage to show the right size, so this looks like a potential interop issue.

Another really odd thing is that outerWidth is smaller than innerWidth, that does look like a clear bug too.

We don't yet return the layout viewport for window.{innerWidth,innerHeight}.

See Also: → 1598487

How not? We return the right number after load, where does it come from?

So, in this case, the value is the visual viewport size, and at the moment we get the correct value the visual viewport size == the layout viewport size. I am not saying bug 1598487 fixes this issue, it's just a "SeeAlso" bug.

Oh, maybe bug 1598487 will fix this, if, when we get the wrong value the layout size is the correct one. I am not sure though.

Boo, my memory was totally out-dated. We haven't returned the visual viewport size for window.{innerWidth, innerHeight) for a while.

Severity: -- → S3
Assignee: nobody → botond
Status: NEW → ASSIGNED

I have a fairly straightforward fix for this, but note that it does not fix the related case where there is a meta-viewport tag with an explicit width. In that case, innerWidth may be evaluated before the DOMMetaAdded event for the meta-viewport tag arrives, in which case the info from the tag isn't available yet.

Pushed by bballo@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b5d0e150491e Ensure initial viewport is computed before reporting innerWidth. r=emilio

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:botond, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(botond)

The patch caused a test failure that requires investigation before I can re-land.

I will take a look when I get a chance, but I have higher priority things to look at right now.

Flags: needinfo?(botond)

Not sure when I'll get a chance to get back to this.

Assignee: botond → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: