Cannot get content height from UIWebView/WKWebView

Since iOS16.4 I cannot retrieve proper content height from my UIWebView. I've tried updating it to WKWebView but result is the same. I need to put this webView inside UITableViewCell so user will scroll through document using tableView scroll - not internal WebView scroll. To do this I need to set frame of webView to be the same as the whole document frame.

I used to get height value from UIWebView like this:

CGFloat documentHeight = [[webView stringByEvaluatingJavaScriptFromString:@"Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);"] floatValue];

And accordingly from WKWebView:

[webView evaluateJavaScript:@"Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);" completionHandler:^(id _Nullable height, NSError * _Nullable error) {} }];

Using Debug View Hierarchy I've found that WKWebView have many subviews of type WKCompositingView and the top of them have height equal to height of whole document. But this is internal view and I cannot get it in the correct way.

I've check it with iOS16.5 and this issue still occurs. What can I do?

Cannot get content height from UIWebView/WKWebView
 
 
Q