<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>191872</bug_id>
          
          <creation_ts>2018-11-20 17:50:17 -0800</creation_ts>
          <short_desc>WkWebView does not set the `env(safe-area-inset-*)` CSS variables until some arbitrary time after page load.</short_desc>
          <delta_ts>2026-02-18 19:41:48 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>Other</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 12</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chet Corcos">ccorcos</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>brian.arpie</cc>
    
    <cc>carlosj-webkit-bugzilla</cc>
    
    <cc>fotis.papadogeorgopoulos</cc>
    
    <cc>kainosnoema</cc>
    
    <cc>makhlonov</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>super.xhmm</cc>
    
    <cc>thorton</cc>
    
    <cc>version.ru</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1480642</commentid>
    <comment_count>0</comment_count>
    <who name="Chet Corcos">ccorcos</who>
    <bug_when>2018-11-20 17:50:17 -0800</bug_when>
    <thetext>This app linked to below shows an html webpage inside a WKWebView that measures the env(safe-area-inset-*) css variables.

You will notice that these variables are not available on the initial load of the app, or after the window load event, or the document DOMContentLoaded event. These CSS variables only seem to be available at some arbitrary time after the app is loaded.

However, if you open up the same webpage (http://localhost:8000/) in iOS Safari in landscape mode and hit refresh, you&apos;ll notice that these CSS variables are available at initial load time.

https://github.com/ccorcos/WkWebView-Safe-Area-Inset-Bug

Please try it out and give it a spin.

```
git clone https://github.com/ccorcos/WkWebView-Safe-Area-Inset-Bug
cd WkWebView-Safe-Area-Inset-Bug
# Server the index.html file
python -m SimpleHTTPServer 8000
# Open Xcode and run the app.
open WebViewBug.xcodeproj
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1480651</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-11-20 19:01:59 -0800</bug_when>
    <thetext>&lt;rdar://problem/46193462&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1644888</commentid>
    <comment_count>2</comment_count>
    <who name="Brian Arpie">brian.arpie</who>
    <bug_when>2020-04-23 11:57:27 -0700</bug_when>
    <thetext>Any update on this bug? I can reproduce on iOS 13.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921685</commentid>
    <comment_count>3</comment_count>
    <who name="">super.xhmm</who>
    <bug_when>2022-12-23 09:47:39 -0800</bug_when>
    <thetext>Same problem here for ios 16, this issue caused the fixed bottom button had a sudden jump when page doms were some complicated, because the first render safa-area-inset-bottom was zero, next render it become 34px,   but when page was simple, no jump happened</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921686</commentid>
    <comment_count>4</comment_count>
    <who name="">super.xhmm</who>
    <bug_when>2022-12-23 09:47:57 -0800</bug_when>
    <thetext>Same problem here for ios 16, this issue caused the fixed bottom button had a sudden jump when page doms were some complicated, because the first render safa-area-inset-bottom was zero, next render it become 34px,   but when page was simple, no jump happened</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1929105</commentid>
    <comment_count>5</comment_count>
    <who name="Evan Owen">kainosnoema</who>
    <bug_when>2023-01-27 17:53:15 -0800</bug_when>
    <thetext>We&apos;re also struggling with this bug still in iOS 16 still. All of the safe-area-inset-* CSS env vars are zero until shortly after the webview is initialized sub-second, but noticeable). It happens both when first launching an app into a WKWebView and also restoring after the app&apos;s been suspended. Because it&apos;s non-deterministic, it&apos;s very hard to work around manually.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>