<?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>274773</bug_id>
          
          <creation_ts>2024-05-28 04:46:24 -0700</creation_ts>
          <short_desc>env(safe-area-inset-*) always returns 0</short_desc>
          <delta_ts>2024-06-04 04:47:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ben Frain">contact</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>koivisto</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2038173</commentid>
    <comment_count>0</comment_count>
      <attachid>471525</attachid>
    <who name="Ben Frain">contact</who>
    <bug_when>2024-05-28 04:46:24 -0700</bug_when>
    <thetext>Created attachment 471525
reduction of the safe area reading technique

For the longest time it has been possible to get the value or the iOS safe areas using the following technique:

```css
:root {
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}
```

And then read that value with JS:

```js
getComputedStyle(document.documentElement).getPropertyValue(&quot;--sat&quot;)
```

However this no longer works. I have tried adding this behind a timeout of 5s but it remains at zero. Attachment is a reduction of the technique.

The environment variable should resolve to the safe area inset value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2038207</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2024-05-28 09:36:58 -0700</bug_when>
    <thetext>Thank you for the report. Could you please specify your exact iOS version, and also provide detailed steps to reproduce?

Notably, I cannot reproduce this in landscape orientation on iPhone 15 Pro, but I have a newer WebKit build. It is AFAICT expected to get zeroes in portrait orientation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2038222</commentid>
    <comment_count>2</comment_count>
    <who name="Ben Frain">contact</who>
    <bug_when>2024-05-28 10:49:12 -0700</bug_when>
    <thetext>Hi Alex, 17.5.1. 

But yes, I was expecting a value back in portrait, as there used to be in prior versions. 

Could you clarify why this now returns 0px? How do we account for the dynamic island area etc in JS?

Are there any recents posts/docs on the WebKit blog that explain the newer behaviour?

Thanks, Ben</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2038276</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2024-05-28 14:05:59 -0700</bug_when>
    <thetext>What makes me say it is that there are no scroll bars or anything else to avoid in this test case. Maybe a test case with more content and scrolling also gets 0, and that&apos;s more obviously an issue?

I&apos;m not an expert on this feature, hopefully one of the folks I CC&apos;ed can chime in with a deeper answer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2039620</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-06-04 04:47:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/129213964&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>471525</attachid>
            <date>2024-05-28 04:46:24 -0700</date>
            <delta_ts>2024-05-28 04:46:24 -0700</delta_ts>
            <desc>reduction of the safe area reading technique</desc>
            <filename>safe-area-tester.html</filename>
            <type>text/html</type>
            <size>1613</size>
            <attacher name="Ben Frain">contact</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDx0aXRsZT48L3Rp
dGxlPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiIC8+CiAgICA8bWV0YQogICAgICBuYW1lPSJ2
aWV3cG9ydCIKICAgICAgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxl
PTEuMCwgbWF4aW11bS1zY2FsZT0xLjAsIHVzZXItc2NhbGFibGU9bm8sIHZpZXdwb3J0LWZpdD1j
b3ZlciIKICAgIC8+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHN0eWxlPgogICAgICA6cm9vdCB7
CiAgICAgICAgLS1zYXQ6IGVudihzYWZlLWFyZWEtaW5zZXQtdG9wKTsKICAgICAgICAtLXNhcjog
ZW52KHNhZmUtYXJlYS1pbnNldC1yaWdodCk7CiAgICAgICAgLS1zYWI6IGVudihzYWZlLWFyZWEt
aW5zZXQtYm90dG9tKTsKICAgICAgICAtLXNhbDogZW52KHNhZmUtYXJlYS1pbnNldC1sZWZ0KTsK
ICAgICAgfQogICAgPC9zdHlsZT4KICAgIFRoZSBzYWZlIGFyZWEgaW5zZXRzIGZvciB0aGlzIGRl
dmljZSBhcmU6CgogICAgPHA+VG9wOiA8c3BhbiBpZD0idG9wIj48L3NwYW4+PC9wPgoKICAgIDxw
PkJvdHRvbTogPHNwYW4gaWQ9ImJvdHRvbSI+PC9zcGFuPjwvcD4KCiAgICA8cD5MZWZ0OiA8c3Bh
biBpZD0ibGVmdCI+PC9zcGFuPjwvcD4KCiAgICA8cD5SaWdodDogPHNwYW4gaWQ9InJpZ2h0Ij48
L3NwYW4+PC9wPgogICAgPHNjcmlwdD4KICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAg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lLmxvZyhzYXQpOwogICAgICB9LCAxMDAwKTsKICAgIDwvc2NyaXB0Pgog
IDwvYm9keT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>