<?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>264043</bug_id>
          
          <creation_ts>2023-11-01 09:52:16 -0700</creation_ts>
          <short_desc>position: absolute parent breaks flex child aspect-ratio</short_desc>
          <delta_ts>2024-04-11 18:45:28 -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>Layout and Rendering</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=272527</see_also>
          <bug_file_loc>https://jsfiddle.net/390wb164/show</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="marcel laverdet">marcel.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>709922234</cc>
    
    <cc>ahmad.saleem792</cc>
    
    <cc>bfulgham</cc>
    
    <cc>sgill26</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1989176</commentid>
    <comment_count>0</comment_count>
    <who name="marcel laverdet">marcel.webkit</who>
    <bug_when>2023-11-01 09:52:16 -0700</bug_when>
    <thetext>I don&apos;t know the cause of this issue but I think the example code shows the problem clearly. Two identical flex containers contain some images. The images have `aspect-ratio:1` set. The first &quot;collection&quot; div is sized with &quot;height:100%&quot;, and the images are appropriately sized. The second &quot;collection&quot; div is sized with &quot;position:absolute;inset:0&quot; and the images are not sized correctly.

In a more complicated example the images were sized correctly but the width of the container was the size that it *would have been* if aspect-ratio was not applied. It is just total anarchy between aspect-ratio and flex.

```
&lt;!doctype html&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;style&gt;
			img {
				aspect-ratio: 1;
				height: unset;
				width: unset;
			}

			.holder {
				height: 200px;
				position: relative;
			}

			.collection {
				display: flex;
				overflow: auto;
			}
		&lt;/style&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;div class=&quot;holder&quot;&gt;
			&lt;div class=&quot;collection&quot; style=&quot;height: 100%&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
			&lt;/div&gt;
		&lt;/div&gt;
		&lt;div class=&quot;holder&quot;&gt;
			&lt;div class=&quot;collection&quot; style=&quot;position: absolute; inset: 0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
				&lt;img height=&quot;536&quot; width=&quot;354&quot; src=&quot;https://fastly.picsum.photos/id/237/536/354.jpg?hmac=i0yVXW1ORpyCZpQ-CknuyV-jbtU7_x9EBQVhvT5aRr0&quot;&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1989206</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2023-11-01 11:39:55 -0700</bug_when>
    <thetext>Did this work in older Safari versions?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1989207</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-11-01 11:40:06 -0700</bug_when>
    <thetext>&lt;rdar://problem/117807518&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1989254</commentid>
    <comment_count>3</comment_count>
    <who name="marcel laverdet">marcel.webkit</who>
    <bug_when>2023-11-01 14:14:23 -0700</bug_when>
    <thetext>&gt; Did this work in older Safari versions?

Nope, I tried 15.6 and 16.6.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1989291</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-11-01 16:13:35 -0700</bug_when>
    <thetext>Changed Comment 0 test case in JSFiddle and added to URL field as well.

Broken in Safari Technology Preview 182 as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1989871</commentid>
    <comment_count>5</comment_count>
    <who name="marcel laverdet">marcel.webkit</who>
    <bug_when>2023-11-03 18:18:21 -0700</bug_when>
    <thetext>Here is a simplified example of the other condition I was talking about. In this example I&apos;ve removed `aspect-ratio` entirely but there is another problem. At the end of the scrollable div there is a great deal of extra empty whitespace. The client area of the div is 10256 which is what the div *would have been* if we didn&apos;t constrain the image dimensions with CSS. You can confirm by disabling the `height:100%` declaration in the inspector and observe that the size of .collection remains the same.

My spidey senses tell me that this issue is related to the same one in the original comment but please let me know if I should open a new ticket.

```
&lt;!doctype html&gt;
&lt;html&gt;

&lt;head&gt;
	&lt;style&gt;
		.container {
			display: flex;
			overflow: auto hidden;
			height: 500px;
		}

		.collection {
			white-space: nowrap;
		}

		img {
			height: 100%;
		}
	&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div class=&quot;container&quot;&gt;
		&lt;div class=&quot;collection&quot;&gt;
			&lt;img src=&quot;https://staging.st.braidusercontent.net/i/vCnu2oMwmmAukqp-8-gUz3CtMII/53229687476_fa5af821aa_k.jpeg&quot;&gt;
			&lt;img src=&quot;https://staging.st.braidusercontent.net/i/vCnu2oMwmmAukqp-8-gUz3CtMII/53229687476_fa5af821aa_k.jpeg&quot;&gt;
			&lt;img src=&quot;https://staging.st.braidusercontent.net/i/vCnu2oMwmmAukqp-8-gUz3CtMII/53229687476_fa5af821aa_k.jpeg&quot;&gt;
			&lt;img src=&quot;https://staging.st.braidusercontent.net/i/vCnu2oMwmmAukqp-8-gUz3CtMII/53229687476_fa5af821aa_k.jpeg&quot;&gt;
			&lt;img src=&quot;https://staging.st.braidusercontent.net/i/vCnu2oMwmmAukqp-8-gUz3CtMII/53229687476_fa5af821aa_k.jpeg&quot;&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1989874</commentid>
    <comment_count>6</comment_count>
    <who name="marcel laverdet">marcel.webkit</who>
    <bug_when>2023-11-03 18:32:05 -0700</bug_when>
    <thetext>If you have any insight into the direct cause of this issue please do share. In my latest example the most modern CSS property is `display:flex` which is more than a decade old at this point. It seems like &quot;rendering a container of images&quot; should be easy pickings for most web browsers so I&apos;m kind of bewildered that the repro example is really this simple. This issue is hitting us pretty hard and besides &quot;don&apos;t use flex in any parent&quot; we&apos;re kind of at an impasse. The workaround now is to directly provide a height &amp; width for all images which are rendered in a container with other images.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>