-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS minifier transforms translate3d(0,0,0)
to translate(0)
, breaking layouts in Safari
#2057
Comments
translate3d(0,0,0)
to translate(0)
, breaking Safari translate3d(0,0,0)
to translate(0)
, breaking layouts in Safari
Looking at the code I notice the minifier is doing a whole bunch of things to 3d transforms. The problem with this is as CSS authors we use 3d transforms to deliberately trigger hardware acceleration, as well as to solve rendering problems in Safari. I would really rather ESBuild was not messing with these, as the transformed result is not as intended by the author: esbuild/internal/css_parser/css_decls_transform.go Lines 252 to 278 in 80c92d4
esbuild/internal/css_parser/css_parser_test.go Lines 1585 to 1595 in 2734bbf
|
Please provide a small test case that demonstrates a rendering difference. |
Indeed, this conversion is not safe. |
I still need a small test case that demonstrates a rendering difference. A test is necessary to determine which transforms are safe. I have attempted to read browser source code for this but I still can't verify things without a test case. Here's what I found for WebKit: |
Here is a test case: https://stephen.band/test/css-transform.html And here is a screenshot of that page, scrolled to half-way down in Safari: The orange and yellow blocks both have 100% height, relative position, and a greater z-index than the red block, which has 50% height and is stuck to the bottom. Here we see the red block over the top of the yellow. This never happens to the orange block. The yellow block has This can be observed in Safari desktop and Safari iOS. Note that the effect is sometimes intermittent - Safari does seem to update itself sometimes and render correctly after a moment. |
Thanks for the test case. I was able to reproduce the bug. I verified that the following transforms trigger the bug in Safari:
and the following transforms do not:
|
I think this is good (that we no longer transform 3D into 2D) as one can use a 3D transform (often with 0,0,0) to just force the rendering being made by the GPU. |
@evanw Hi. I have now been able to deploy these changes to production and can confirm it fixes all our woes. Thank you very much for your help, and for ESBuild, which rocks. |
ESBuild's CSS minifier transforms
translate3d(0,0,0)
totranslate(0)
. Unfortunately in Safaritranslate3d(0,0,0)
is a useful hack, forcing it to respectz-index
layering correctly, wheretranslate(0)
does not have the same effect.The text was updated successfully, but these errors were encountered: