WKWebView reports different size for <HTML> on iOS vs MacOS

I use a WKWebView in the iOS and MacOS versions of my App. Both display the same HTML string (generated within the APP by the same shared class). The only difference in the HTML between iOS and MacOS is that on iOS this META is added to the <head>:

Code Block
<meta name="viewport" content="initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, shrink-to-fit=NO, user-scalable=YES">


On MacOS the DOM inspector reports the correct page size (size of the <HTML>) 1864x844 element. And javascript run in the WKWebView after the page is fully rendered reports the same size given by the DOM inspector via these:
  • document.documentElement.scrollWidth

  • document.documentElement.scrollHeight

But, on iOS BOTH the DOM Inspector (looking at a device in debug mode) as well as the same javascript run in the WKWebView reports an incorrect size for the <html> element, 768x895

The size it reports appear to be the visible viewport and this is long after the page was fully rendered.

This is presenting a real problem because I need to be able to get the correct page size via Javascript run IN the page via the WKWebView evaluateJavaScript function.

Interestingly though the WKWebView scrollView's contentSize IS correct.

Any thoughts on what the heck is going on and how to get the correct size or is this an iOS WKWebView bug?!

I've posted the same question along with pictures over on StackOverflow. The pictures help: [Same Question With Illustrative Pictures showing problem HERE].(https://stackoverflow.com/questions/66772470/wkwebview-size-fo-html-element-is-inconsistent-between-ios-and-macos)
I did discover that by adding css of "display:table;" to the HTML element the DOM inspector and javascript will return the correct page size for iOS (display:block) has no effect. The style is not needed on macOS and neither does it hurt.
Given the deafening silence, presumably this is a bug. Bug report filed here: https://feedbackassistant.apple.com/feedback/9057027

WKWebView reports different size for &lt;HTML&gt; on iOS vs MacOS
 
 
Q