[AC-6232] Regression - Webview deviceHeight reports incorrect number
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2019-08-19T22:11:14.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | ios, webview |
Reporter | roeland p |
Assignee | Shak Hossain |
Created | 2019-04-29T11:14:57.000+0000 |
Updated | 2019-08-19T22:11:15.000+0000 |
Description
I have webview anomalies on ios 12.1 simulator Ti.SDK 8. Looking to make a true fullscreen webview with a local html file.
Ti.WebView itself honours the full device width / height, as can be seen from the red borders, however contents inside, act weirdly (see image of 2 scenarios using viewport-meta tag)
When using Safari-Developer inspection I notice the actual -element /
document.body.clientHeight = 647
is reporting not the "Ti.UI.WebView"-s height and off by 20px in this iPhone 8 simulator (which corresponds with the safeArea padding.top fyi)
Ti.Webview.toImage().height = 667
but inside the webview:
document.body.clientHeight = 647
===
When running the same samples on Ti.SDK 7.5.2 GA, the deviceHeight inside the webview reports correctly and the webview's HTML uses the full height as the Ti.UI.Webview has.
Might be related to TIMOB-26984 ?
Attachments
File | Date | Size |
---|---|---|
7.5.2-shows ok.png | 2019-04-29T11:17:37.000+0000 | 713436 |
anomalies.png | 2019-04-29T11:08:06.000+0000 | 3384035 |
iPhone7-contain-landscape.png | 2019-05-01T02:24:42.000+0000 | 143850 |
iPhone7-contain-portrait.png | 2019-05-01T02:24:39.000+0000 | 194844 |
iPhone7-cover-landscape.png | 2019-05-01T02:25:35.000+0000 | 145787 |
iPhone7-cover-portrait.png | 2019-05-01T02:25:32.000+0000 | 196442 |
iPhoneX-contain-landscape.png | 2019-05-01T02:24:33.000+0000 | 147937 |
iPhoneX-contain-portrait.png | 2019-05-01T02:24:26.000+0000 | 214441 |
iPhoneX-cover-landscape.png | 2019-05-01T02:25:23.000+0000 | 143486 |
iPhoneX-cover-portrait.png | 2019-05-01T02:25:18.000+0000 | 217760 |
WebViewInsetsTest.js | 2019-05-01T02:28:57.000+0000 | 3401 |
wkwebviewtest.zip | 2019-05-17T08:19:07.000+0000 | 8662963 |
I haven't tried this myself, but I'm pretty sure this can be solved via a
<meta/>
viewport tag. For example...The key thing is the
viewport-fit=cover
which tells theWKWebView
to ignore the safe-ares padding and allow content to be overlapped by the top status bar, iPhone X notch, and to not compensate for rounded corners.@joshua please see the (2nd) attached image (anomalies.png) in the issue which has screenshot running with 2 different variations on "viewport" including an anomaly on the bottom of the viewport (right screenshot) when working with the "viewport-fit="cover" tag. It seems that with vieport-fit-cover indeed the safearea padding-top is put to 0, however WKwebview.innerHeight seems not aware that has those extra pixels available. (just a guess).
maybe this is due to me opening my "test"-controller from index.js which in my case just hosts a "tabgroup" and not a "window" element.
I've tested this with the following code.
By default, the
WKWebView
usesviewport-fit=contain
, which will inset the web view's contents to avoid overlap. I took screenshots of the above code with the "contain" setting on iPhoneX and iPhone7. !iPhoneX-contain-portrait.png|thumbnail! !iPhoneX-contain-landscape.png|thumbnail! !iPhone7-contain-portrait.png|thumbnail! !iPhone7-contain-landscape.png|thumbnail! When I changed the code to useviewport-fit=cover
, I see the following on iPhoneX and iPhone7. !iPhoneX-cover-portrait.png|thumbnail! !iPhoneX-cover-landscape.png|thumbnail! !iPhone7-cover-portrait.png|thumbnail! !iPhone7-cover-landscape.png|thumbnail! Note that Android does not support theviewport-fit=contain
setting. So, if you're using a translucent status bar or navigation bar as shown in my above code, then they will always overlap the content.Hello [~rpl], Can you follow up here? What's the status of your issue?
@sharif sorry for the non response, got buried in email. I've attached a barebones test project where I am using the Meta key viewport settings as instructed and extendSafeArea=true padding What you will notice is that (testing on iphone 8) the console logs are as followed: [INFO] Ti.Platform.displayCaps.platformHeight 667 [INFO] data = "from webview (onload)- window.innerHeight ---> 647 Inside the webview - onload, somehow reports window.innerHeight = 647. (so minus statusbar height) BUT, when i change the window to "fullscreen = true" the window.innerHeight is reporting the correct behaviour. So either I am not understanding window.innerHeight or something is off. The webview seems to be running from top to bottom of screen tho. [^wkwebviewtest.zip]
more testing and digging into this behaviour. When using the
screen.height
property it reports the correct number. So i'm still not sure ifwindow.innerHeight
is intended to return a different value (w/o safeAreapadding) but the webview itself uses the full height including the safeAreapadding area :) for now I will detect if my webview is on IOS and use the screen.height property for properly scaling some divs. Thanks all for helping with this. I hope my comments are still valuable. kr roeland[~rpl], Thanks for your valuable comment. We appreciate it. Are you able to get that sorted out? Please let us know if you need more help with this issue.
Hello, We have not heard back from you since our last update. I just wanted to follow up with you about this issue? Are you still experiencing this problem? Please let us know if you need more help with this issue.
[~rpl], I just wanted to follow up and check the status of your issue. We have not heard back from you since our last update.Did you manage to resolve the problem? Let us know the update.