Convopage
See the entire conversation
Alexis Beingessner
@Gankro
omg whatsapp's webapp has a 4k sprite sheet because it's laid out diagonally
140 replies and sub-replies as of Sep 19 2017
❄SnowMew❄
@SnowMewPlays
But why...
Alexis Beingessner
@Gankro
we've been trying to guess reasons for like 15 minutes. It's trashing firefox b/c we "cache" svg to raster...
Cole Campbell
@zwlegendary
I'm going to guess this originates with this "illuminating" blog post.
aaronbarker.net/2010/07/diagon…
Nicolas Silva
@nicalsilva
Worst. advice. ever. -_-
Shaun O'Connell
@ndorfin
How else would you create a PNG sprite without creating extra HTML nodes in browsers that barely support CSS 2.1?
Shaun O'Connell
@ndorfin
It seems pretty straightforward that instead of refactoring their use of sprites, they just switched from PNG to SVG.
Nicolas Silva
@nicalsilva
Those extra nodes are well worth it, trust me.
Nicolas Silva
@nicalsilva
Those extra nodes are well worth it, trust me
ティン・ルーフ
@tinruufu
telling, i suppose, that this website's insistence on having a 21px frame crippled my computer for a bit while this page tried to render
ティン・ルーフ
@tinruufu
scrolling still performs extremely poorly once everything has settled
Dan Burzo
@danburzo
It's an article from 2010, I think we can cut it some slack.
Michael | ガトジイマイケル
@mgattozzi
"I didn’t know if that meant this was a new idea, or a bad one that no one was willing to publish. I’m hoping it’s the former." Bad news guy
Vlad Filippov
@vladikoff
"Diagonal is the only layout where all browsers behaved the same" (Safari issues, etc)
Creating SVG Sprites using Gulp and Sass
Following on from the previous blog post, we walk through the process we have for creating and maintaining our SVG sprites with Gulp and Sass by using custom mixins and functions
liquidlight.co.uk
John "______" Briggs
@robotonical
Laziness? Only need 2-3 variables instead of 3-4 to access the sprite?
Fiora Aeterna
@FioraAeterna
you'd need even fewer if it was 1D!
John "______" Briggs
@robotonical
Hahaha, I didn't think of that. Next step: save each sprite as a frame in a gif, and write a js lib to split them apart.
dan
@ijks_w
i can't even
Dennis Bednarz
@DennisBednarz
i wanna cry
Jasper Russell
@MxBombardier
I guess... it saves you having to store... two UVs??? yeah i don't know
dog, but wearing hat
@zmodes
"easier" than interrogating each sprite for height/width in order to properly organize. gross. don't let your SNES carts see this.
logical fal'cie 🏗️
@brightsuzaku
(rhetorical) why
Ash Matheson
@nuclearfossil
There has to be more to this than just "oopsie".
Spencer L.
@redneptonic
Wtf
Preslav Rachev
@preslavrachev
Is there any practical reason for this?
Lluis Gerard
@lluisgerard
uhm… to avoid having to save/use x AND y? With just one point value you can get the image position
RPG Hacker
@RPG_Hacker
Since the icons are variable width and height, wouldn't you need the U/V coordinates, anyways?
Lluis Gerard
@lluisgerard
I was thinking… If you have an array with all the points, you could get the image position with n and it’s size with n+1
RPG Hacker
@RPG_Hacker
You're right, that would not require x/y. Somehow I read your last comment as "without x/y and width/height" and was like "wait, how...". 😅
Literallie
@_xxyy
an extra integer variable vs a significantly bigger image seems like a weird tradeoff to me
EU-WEST-2
@marekventur
I've just checked - it's an svg, so the whitespace doesn't really matter
Alexis Beingessner
@Gankro
It super matters if you think about how svgs make it to your screen
EU-WEST-2
@marekventur
It's not optimal, but I would assume browsers are culling svgs nowadays? But I'm just guessing here, so I'll shut up ;)
Maik Macho
@0x0ade
From a file size standpoint, it doesn't matter. From a "this will end up formatted as bitmap in your GPU's memory" standpoint, though... ow.
EU-WEST-2
@marekventur
oh, sorry, hadn't thought about GPU rendering. I'll take it all back, sorry.
BunnyOverlord
@co60ca
I wanna believe this is some weird copy paste error in an automatic tooling for the sprite sheet.
Ilya
@13xforever
Well, it’s an svg, and that’s how your browser renders it. You use separate glyphs from it, so there’s no issue
web.whatsapp.com/img/30c5efbd3b…
Fiora Aeterna
@FioraAeterna
that doesn't answer the question "why"
Andy Osthoff
@TinyConstruct
Someone else suggested this... :(
aaronbarker.net/2010/07/diagon…
Ilya
@13xforever
also I see that the issue is that at least Firefox is caching the rasterized version...
Alexis Beingessner
@Gankro
In fact, svg makes this 10x worse because rendering one icon at 100% scale and another at 200% creaters two rasters of the whole thing
James Campbell
@jcampbell_05
can you cache the viewport of the sprite ?
Adam Martin
@t_machine_org
That's not SVG making it worse though, TBF. That's Firefox making it worse. Although ironically our open-source lib has same problem LOL :)
Fiora Aeterna
@FioraAeterna
if multiple popular, widely used implementations of a format have a problem you can't really separate the problem from the format
Adam Martin
@t_machine_org
Yes, yes you can. So our lib by default DOES NOT do this, because it's a terrible implementation. By default it renders only visible subset
Adam Martin
@t_machine_org
...on demand. And it caches the set of render-instructions-as-clipped-raster - not the WHOLE DAMN DOCUMENT :). But in raster mode, it works
Adam Martin
@t_machine_org
...same as described here. Assumption: if you really REALLY want to raster the whole document (dev has to actively tell API this), you can.
Adam Martin
@t_machine_org
...unless you have a small doc that you're using as a single sprite, in which case it flips, and rasters by a special super-quick 1-liner.
Adam Martin
@t_machine_org
So, now I've seen this problem, I'm thinking that I should REALLY add some detection for this - if anyone is subslicing the raster, I should
Adam Martin
@t_machine_org
either provide a better, less lazy implementaiton (I wrote the current raster code, so happy to take blame: I was definitely being lazy!)
Adam Martin
@t_machine_org
...or detect the slicing and throw an assertion/debug warning "Dude, don't do that! Use vector mode instead!".
Adam Martin
@t_machine_org
But either way: to me it's v. interesting problem. SVG is not like other image formats, it's designed to be used more creatively (like this)
Fiora Aeterna
@FioraAeterna
it really doesn't matter whether the fault is in implementation or format because you can't make your users switch implementations
Juha Lindstedt
@pakastin
😂👍
Igor
@gogainda
At least somewhere 4k is useful, wink
Subgay Sadwich
@masklayer
WHY
Philipp
@phppco
John Ripley
@jhripley
This is one of those things which becomes a multi-line comment "// This special case is for <This One App> which does something stupid"
John Ripley
@jhripley
Thinking of how you would do this efficiently just cured my drowsiness on the bus commute in.
Alexis Beingessner
@Gankro
Right now we do the maximally inefficient thing. Oh this one icon was scaled or has a different subpixel offset? Time for another 4k render!
John Ripley
@jhripley
Ideas: Tiling. Compress tiles (most are single-color!). Deferred decode of individual tiles (heuristic). Re-compress image in tiled format.
Alexis Beingessner
@Gankro
Idea #1 is to beg them to stop :)
John Ripley
@jhripley
Idea #0: Inhibit its caching so the resulting data transfer bill makes them stop.
eSyr
@evgsyr
there will be no data transfers since we're discussing rasterisation cache, no?
Stephanie Hobson
@stephaniehobson
Or you could ask them why they're doing it? I know accessibility techniques that require diagonal sprites.
Steve Canon
@stephentyrone
Obviously we need a new image format: block diagonal png.
John Ripley
@jhripley
The obvious solution is therefore for them to rotate the image 45 degrees, encode to png, and unrotate client-side every render.
Steve Canon
@stephentyrone
If they were clever they would skew instead of rotate, but ...
"${benaryorg}"
@benaryorg
could be more inefficient by placing some padding there.
Adam Martin
@t_machine_org
The app isn't being stupid. I maintain an SVG lib. IMHO this is valid, reasonable, use of SVG. It has infinite canvases with non-zero origin
John Ripley
@jhripley
Works for me on my Infinity Browser.
Zach Leatherman
@zachleat
oh no css sprites oh no 😩
TUWAN
@TUWAN_N
Is this a glowy brain meme
mike 🌹
@MikeASchneider
probably a (janky) solution to visual bugs with other icons peeking in above/below or next to the icon that’s supposed to be there
Ehsan Kia
@ehsankia_
That would be solved with padding. This seems like a bug: both the x and y are bumped in the inner loop, instead having y in the outer loop.
Senpai Ariin☕️holic
@Ariin_phd
What the... w-why?!?!!
Z-Swan Datamoon
@pyromuffin
ahahahahahah
Kipper
@DeccoPhin
Wtf
Kipper
@DeccoPhin
What a waste of room
David Manning
@davidlymanning
It’s possible someone is generating this by lazily incrementing x and y and just never thought about what that meant
Nick
@uncletrunks
ladies and gentlemen, web development
MOFT
@mikejmoffitt
Maybe it's so they can index position with only one position index, controlling X and Y at the same time. Was this really worth it?
Slaşçkrën
@Slashscreen
What is the point
SandPile
@_Sand_Pile
I'd like to think some Graphical artist sent it in like that. The programmers were too unsocial to ask them to change.
Tyler Glaiel 🥑
@TylerGlaiel
wtf
Jeff 🦄
@peabnuts123
(No comment)
James Bosworth
@fltwhte
Lol sprites
Graham Reid
@GrahamOfLegend
Lol what the hell?
Matt Mirrorfish
@MattMirrorFish
It's a mysteryyyy lol. Idk why it bothered me so much but apparently I am not alone lol
Wimtie
@Wimtie
"simplification"
Radu Popescu
@iradupopescu
Lol, no sparse matrix.
Mike Street
@mikestreety
Sorry if this sounds stupid - but it’s SVG, how would that affect file size?
Mike Street
@mikestreety
Png/jpg I can see how, but with SVG, surely it’s just a few bytes where co-ords are double instead of single didgets?
Alexis Beingessner
@Gankro
not at all; the issue is that it trashes all our (firefox) image caches because we rasterize the whole thing for every requested scale.
Mike Street
@mikestreety
Interesting. I’ve always used diagonal SVG sprites not realising it had perf implications
Alexis Beingessner
@Gankro
Hillariously this would probably be better if it were a png
Mike Street
@mikestreety
Is there a blog post or similar that you know of on this topic? Would be interested to learn more!
Alexis Beingessner
@Gankro
Not really. It was a perf issue that my coworkers were investigating today.
Tanner Bennett
@NSExceptional
Why?
Paul Cuthbertson🇪🇺
@paulcuth
What are the advantages to having a diagonal layout?
Mike Street
@mikestreety
You can have unlimited height or width of your pseudo element with nothing else sneaking in (should you need to)
Mike Street
@mikestreety
We also do our sizing in ems, which can pixel round oddly and used to show an edge of the next icon on some browsers at some fonts sizes
Adam Martin
@t_machine_org
That's an interesting choice. I guess made sense many years ago, and never got picked up on? Obvs today, knowing retina etc, wouldnt repeat?
Alexis Beingessner
@Gankro
*shrug* only so much time in the day to optimize stuff. works ok if the input isn't completely degenerate like this.
Adam Martin
@t_machine_org
Only bit I dislike is the implied assumption that SVG is treated as a bitmap with a funny name ;). Vector should be handled differently IMHO
Adam Martin
@t_machine_org
IME: people who choose a vector format do it precisely because stuff like this use-case is simple and VERY efficient. That's the point of it
Adam Martin
@t_machine_org
eg early win of our lib was to render e.g. Wikipedia's *massive* earth-map fast on iPhone3+. Great use of vector: zoomable, but: efficient.
Dread 'Pirate' Cruz
@Soulmech
WHY
Eduardo Krustofski🔵
@edmz
Seems like a fun problem for a topologist
Pete Lewis
@PJayB
TIL WhatsApp has a web app.
Kieran Nee
@kieran_nee
It's v useful, I use it at work with PushBullet so I can reply quicker and better without context switching to my phone
Joe Groff
@jckarter
What sort of vector space is this diagonal matrix for
Alexis Beingessner
@Gankro
It's trying to solve 1 + 2 + 3 + 4 + 5 in swiftc
cat lee
@catleeball
WHY
Brody K. Brailsford
@thebigbdot
I've never done any UI work in my life but I feel like this is the wrong way
Pandawan
@PandawanYT
What would be the best way to go about this then? Just pack them one next to the other? Doesn't it not matter since it's SVG?
Alexis Beingessner
@Gankro
We ultimately need to rasterize svgs to render them, and there isn't any optimization in place to guard against this kind of svg
Pandawan
@PandawanYT
So png would be better?
Alexis Beingessner
@Gankro
Ultimately yes, because we wouldn't be forced to rasterize any scale variants
Friedrich Hartmann
@mxfh
SVG has the viewBox property, which should be the size of single icon and shifted around before rasterizing.
How SVG Fragment Identifiers Work | CSS-Tricks
I've talked a good bit about SVG's around here and using it to build an icon system. The beauty of is that you can reference just a part of some SVG define
css-tricks.com
AF | criticaL
@Hihanteki
what the fuck
Stephen Levi O'Neil
@Phevnil
It's 2017 and I can't believe this keeps happening. (Maybe for lazy scaling calculations on all icons at once? Not sure that's reasonable.)
Stephen Levi O'Neil
@Phevnil
Hmm, wait, SVG. Yeah, I've got no good guesses (but maybe the actual reason is something that would count as a bad guess...)
Alexis Beingessner
@Gankro
The running theory is it makes it maximally hard to "see" the other images if you badly mask/clip them
Wolf, Wings optional
@WolfWings
...I'd expect them to use a <symbol> dictionary in the SVG and have everything with a common origin point, or is that bad somehow too?
Pixel
@pixeljavascript
It's easier to request a certain index on the sprite sheet that way plus it's an svg so it doesn't effect size.
Call of Booty
@PomoWarfare
How much did facebook fucking pay for this shit?
matt conte
@mattconte
offset_x = offset_y
DiFFtY
@DiFFtY
well we all have dual octocores & 64GB of RAM nowadays so who cares about performance optimization
STANN
@STANN_co
why?
DJMAN
@digitaljokerman
👌
Fox of Pear
@Gabe_Fox
WHY!? WHY WOULD YOU DO THAT!?
Haaris A M Qureshi
@imaginewizard
Someone explain this to me please
Christina H
@americanwombat
CSS Sprites: What They Are, Why They're Cool, and How To Use Them | CSS-Tricks
This article has been revised and re-written several times since its very first publication in 2007, to keep the information current. The most recent revis
css-tricks.com
Haaris A M Qureshi
@imaginewizard
Ahhhh. XD
Renato CRON
@renato_cron
That's what I call saving performance
Evgen Bodunov
@molind
thanks god they are not game developers.
TheDudeFromCI
@TheDudeFromCI
Reading the comments, it seem these are pretty common. Couldn't you try to detect them and edit the Y coords before rasterizing?
BayekDev
@BayekDev
's worst nightmare
Holy crap
@bleakness_jar
why he do that ?
Sonic's Coolhouse
@sonixcoolhouse
what kind of fucking madman would do this