Top
Best
New

Posted by baldvinmar 13 hours ago

Jelly UI: Soft-body physics for native HTML form controls(jelly-ui.com)
437 points | 146 comments
jlukic 11 hours ago|
Saw the window was a bit laggy so thought I'd delve deeper to figure out what was going on.

This lib runs a a RAF animation loop every 8ms across every component on the page that causes the entire document to repaint.

The comment above appears of the AI generated sort: // One shared animation frame: step every live component, park when idle. // The delta is capped so a background-tab pause never becomes one giant step.

The "JellyEngine" instead of just calculating the jelly animation on pointer events is recalculating for every active component on the page every frame.

This is the kind of thing usually a human notices and says 'dont do that, that is kind of crazy'.

wbobeirne 11 hours ago||
Running a performance profile in Chrome doesn't back this up for me, and looking at the loop it looks like it maintains an active `Set<JellyComponent>()` of which components to update, and clears them out when they stop moving.

Agreed the comments look a bit slop-ish but I don't see anything obviously wrong with its approach, and the core loop is running in microseconds for me when nothing is happening.

jlukic 8 hours ago||
Here's the perf profile, just to clarify.

Cursor idle, viewport on the button examples. 3ms repaint every 8-11ms. Animation frame points to the code i mentioned.

https://postimg.cc/sQpZxxzv

The problem isn't doing work on a website, its if you have an idle task that is taking up a significant portion of the frame budget then its easy to have frame drops when you do significant work like clicking, scrolling, browsing.

Idle work showing up in flamecharts is usually the thing to be cautious of.

Rohansi 6 hours ago||
That's from Lottie, the animations that play in the header and footer of the page. Shrink your window until they disappear and try again.
edoceo 6 hours ago||
Oh, yea, "you're holding it wrong"
raincole 5 hours ago||
? In this very particular case, yeah, the original commenter was holding it wrong, as they inspected the wrong thing. People sometimes hold things wrong and it's okay.
Rohansi 10 hours ago||
> This is the kind of thing usually a human notices and says 'dont do that, that is kind of crazy'.

It's not crazy. That is literally what 99.99% of video games do. They repaint everything constantly, only limited by either your vsync rate or hardware.

Philip-J-Fry 9 hours ago|||
A website shouldn't be pinning CPU or GPU. When people run a game they expect some sort of battery drain. People don't expect that some websites will thrash your CPU/GPU like a game.
Rohansi 8 hours ago||
> A website shouldn't be pinning CPU or GPU.

That's exactly what I was saying. Rendering a few widgets shouldn't pin your CPU or GPU because it's so little work.

This page, however, has an animated SVG and moving DOM elements in the header which consume far more resources than the widgets it is trying to showcase. Compare usage before and after deleting the header element (`section.hero`) in the inspector to see for yourself.

globnomulous 7 hours ago||
> > A website shouldn't be pinning CPU or GPU.

> That's exactly what I was saying. Rendering a few widgets shouldn't pin your CPU or GPU because it's so little work.

Your comment doesn't say this at all:

> > This is the kind of thing usually a human notices and says 'dont do that, that is kind of crazy'.

> It's not crazy. That is literally what 99.99% of video games do. They repaint everything constantly, only limited by either your vsync rate or hardware.

Am I missing something? Are you referring to some other part of the thread?

Rohansi 6 hours ago||
Sorry, I meant to say that it was what I was suggesting. Video games render a lot more than the widgets on that website. Rendering less takes less time, so your `requestAnimationFrame` loop idles longer between executions waiting for vsync, which means your CPU or GPU usage is not pinned.
goobatrooba 7 hours ago||||
> Yes my car is running all night while it stands in front of my house, but it's not really a waste of resources or a nuisance because generators do the same thing.
theodric 7 minutes ago||
It's mining Bitcoin!
adithyassekhar 4 hours ago||||
The state of the web when you want to compare a website to the most intensive thing a pc can do.
pennomi 10 hours ago||||
Presumably in a video game the majority of the screen changes every frame. Not so in web pages.
Rohansi 9 hours ago||
My point was more that rendering a few widgets at 60+ FPS is nothing for anything with a GPU, and everything has a GPU these days.

Anyway, something like this only needs to paint when states change or animations are running. That's an easy optimization to make here if it doesn't do it already. And games don't even bother with it, they repaint all UI even if it doesn't change.

dxdm 9 hours ago|||
Waste the cycles, everyone has too many cycles, is it even waste if the cycles would just go unused, GPUs are expensive, they better do their bit, who's got no GPU, go play somewhere else without your GPU, pal. It's all a game, anyway.

Point being: your comment made me sad and I needed to lighten myself up a bit.

Rohansi 8 hours ago||
Yes, visual effects and animations in UIs burn cycles just to make it look nicer. Doesn't matter if it's a website or the native system UI.

To be clear, I'm not saying it's fine to constantly render when you know nothing changed. I'm saying the load from this should be very small. Most of the performance issues from this page are actually from the header animation, which you can delete in the inspector to see a significant drop in usage (mine went from ~35 to ~6.6 CPU).

altairprime 9 hours ago|||
Video games only get away with this because their energy draw is obvious: one launched the video game, so one expects the power draw. Visiting a web page does not have that action-reaction causality in people’s minds. Having a random web page introduce maximally-inefficient repaints also leads browsers to start reducing timeslices — especially those with any sort of power drain cognizance, such as Safari — which, here, leads to hella janky animations that can’t cope without their inefficient repaint loop.

All this work to replicate the animated blobbiness of Liquid Glass. I thought everyone hated it! So, then, why is this a thing?

TheDong 8 hours ago||
> Visiting a web page does not have that action-reaction causality in people’s minds

It does in my mind. I fully expect visiting any of reddit.com, github.com, notion.so, or meet.google.com to have the chance to pin a cpu core at 100% for as long as the site is open.

At this point, I expect the average webpage to use more CPU than any of the video games I play. The only reason I had to upgrade to my current machine is because a 2021 CPU (intel gen 11) wasn't capable of running notion.so or google meet anymore, it still ran all the video games I care about just fine.

altairprime 8 hours ago|||
As a web developer, I am not included in the perception difference I describe. I am also 0.000001% and not a representative sample of People As A Whole Or Even As A Majority Or Significant Fraction. So while my personal awareness is akin to yours, extrapolating from that towards the masses is a dead end exercise.

CPU bound games examples: Chess, Go, Final Fantasy XIV, Elite Dangerous, and any competent Civilization / 4X or turn-based strategy game. Yes, you can dial up the graphics on these to force them to be GPU bound, but they’re each CPU bound in their own unique ways. Perhaps none such games appeal to you, but as with above, extrapolating from personal preferences is a non-starter.

Non-tech people teach each other to force-quit apps to stop their battery drain. Websites aren’t apps, so their phone ‘randomly’ gets hot sometimes and they either have no idea why or just try closing all tabs in a vague hope that it works. Sometimes a webpage uses up all their data for the month downloading ads and so they stop using the web over cellular at all.

This is the baseline level of competence that improving the web must be aiming for — not ‘web developers will understand that the tab is using lots of battery and must be closed’. Making the web better is not about making the web significantly more battery-hungry, no matter how pretty it might seem. No visual advancement in radio button UX is worth a continuous repaint in JavaScript.

TheDong 7 hours ago||
If the geneva convention didn't ban torture, I'd say that web-developers should be forced to actually try and use the apps they develop.

The websites I mentioned use more cpu and memory than most games in Civilization the series, which are largely competently developed. My previous laptop could play civ 5 at a higher framerate than it could scroll github diffs or notion pages. Civ 5 handled full-speed keyboard input, while notion doesn't let me input text at my roughly 100 wpm typing speed.

I agree that we shouldn't be expecting users to figure out how to close the right tab, however I'm reporting the way things currently are, which is that webpages are poorly optimized messes.

qurren 5 hours ago||
They should also be forced to walk around town with a GDPR cookie banner pasted over their face covering half of their field of view. And then although automatic doors open for most people, for them specifically, the automatic doors shut. The doors are postered with "would you like to subscribe" newsletter ads. They have to manually open each one of them.
pibaker 8 hours ago|||
This is like saying "I fully expect visiting that neighborhood to have the chance of getting mugged." A true statement and an incredibly sad one.
hbcdbff 9 hours ago||||
A website isn’t a videogame
moralestapia 8 hours ago|||
The browser and OS does that as well (unless absolute zero updates and you don't even move your pointer around).

But many smaht people out there don't know that.

ben-schaaf 4 hours ago||
This is just plain false. Retained UIs like the DOM and what your OS uses only ever render when something changes, so the vast majority of the time they sit idle. There's extensive effort throughout the entire stack to do as little work as possible.

For instance, the mouse cursor is composited on the GPU during scanout. That means simply moving your cursor requires zero rendering.

Another example: When typing only the newly typed character and caret are rendered. The rest of your entire screen is reused.

TurkTurkleton 13 hours ago||
Cute (and I mean that sincerely, not sarcastically), and I appreciate that it appears to gracefully degrade for `@media (prefers-reduced-motion: reduce)`, but for the demo site, it would probably be a good idea to allow the user to override that without having to change their system settings, or at least alert them that they won't see the animations.
zdragnar 12 hours ago||
I'm glad I read your comment, I missed that it intentionally gracefully degraded and assumed it was broken, as I'd forgotten I'd set that.
momojo 11 hours ago|||
PSA: Apple menu > System Settings > Accessibility > Motion

These cool demos come up now and again and it always takes me a minute to remember I have reduced motion. But for that minute I was disappointedly clicking around thinking "Whats the big deal?"

baldvinmar 7 hours ago||
Point taken and now you both get notifications as well as a pretty bunny icon to click on, to over rule the system settings.
itishappy 10 hours ago||
I love this, but it does not seem to conform to standard UX best practices.

If I click and hold then move the mouse away to release, I assume an element should not register that as a click. As-is, this is inconsistent: the button registers a click, the checkbox does not.

smilespray 9 hours ago||
I always had this issue when working with Flash developers. A common mantra was "don't reimplement scrollbars unless you can implement all the features a scrollbar comes with." They always had to do more than five iterations and spent days on that scrollbar.
baldvinmar 7 hours ago||
Good catch. I've updated the button logic. The click will no longer trigger if the cursor is outside the button boundary.
orliesaurus 13 hours ago||
If I were younger I would love this. nowadays I spend most of the time tweaking websites to remove this stuff using local stylesheets...or using dark + read mode... how times have changed.
blauditore 11 hours ago||
I like the fact that it gives animated feedback to emphasize what is happening/being altered. Native components don't always do that very well. Animations are not just artsy fluff, they have real UX value (if done right, of course).
red_hare 8 hours ago|||
I think the trick to using libraries like this is to not go all in on them. Applying these effects to every element would be garish.

But for a single like button, an effect slider, or magic search bar? It would be be a lovely touch.

kfarr 11 hours ago|||
Honestly same, I was less interested in the styling and just interested in the immediacy of response which is ironically missing in a lot of modern ui
ryanmcbride 11 hours ago||
I flip back and forth every year or so between wanting more fun in my software, and wanting it to get the hell out of my way.
Kinetic_Coffee 7 hours ago||
"There's a time and place for everything, but not now!"

I think now that llms make it super easy to add anything that its important not to add everything.

jszymborski 10 hours ago||
This comment is for like three people on HN, but anybody remember when Paul Neave had a website/blog/showcase (c.2007-2010ish?) where the borders of the page had similar jelly effect? That was achieved with Flash back in the day.

Neave was a personal hero of mine back then... hope you're well if you're reading this!

DrSiemer 54 minutes ago||
Haha, yep, first thing I thought of as well. I still have a offline copy of that exact site saved somewhere.
rglover 3 hours ago||
I used to "get high" as a kid on the spiral illusion thing he built :)
JoshTriplett 6 hours ago||
It's cute. But the reaction time on some of the controls is so awful. If I click and drag the slider control back and forth, it lags behind the mouse cursor substantially. It should feel like it's stuck to the mouse cursor like glue.

By contrast, most of the other controls do seem to stick to the cursor, such as jelly-resizable.

Also, the "Placeholder" control seems to fail to actually make the placeholder disappear when clicked in.

nerdsniper 13 hours ago||
I'm having trouble identifying any physics at all in this UI design system.
hedgehog 13 hours ago|
The library does respect the client-side reduce motion setting (by disabling all animated effects).
nerdsniper 11 hours ago|||
EDIT: OH MY GOD THAT IS A HUGE CHANGE!! On MacOS: Settings -> Accessibility -> Display -> Reduce Motion. I had no idea that was on. I like motion, I wouldn't have set this myself!

------------------

Original:

How does that make anything about this "physics-based"? I'm not being snarky, I'm genuinely trying to figure out what part of this is completely going over my head. I don't see any "soft-body physics" interactions, but maybe I don't understand what to look for.

I don't see any deformation or elastic collision physics, and those are usually the most obvious things that I associate with "soft bodies" in engineering/physics.

dpark 6 hours ago|||
> I like motion, I wouldn't have set this myself!

You sure about that? “Turn on Reduce Motion” was a common bit of advice for people who were looking for ways to make Liquid Glass livable.

ddejohn 11 hours ago||||
I am similarly very confused. Tried in multiple browsers, including a stock chrome install where I haven't messed with any animation settings.
bogwog 11 hours ago|||
I see two options:

1. The AI they used called it "physics-based" as a hallucination (probably due to the popular "JellyCar" game), and they went with it because they don't know better.

2. They don't know better, so they asked the AI for a "physics based" system, and the AI was too sycophantic to correct them.

Either way, it's slop.

_def 12 hours ago||||
Oh, thanks for the hint. I actually don't like this - similarly to dark mode setting detection. But I guess thats more a criticism on the OS preferences not being granular enough.
TylerE 8 hours ago||
It's not something for you to not like. Many of us that have visual deficiencies and have that setting turned on for a reason.
dgellow 12 hours ago||||
Oh thanks, I was also pretty confused
hyperhello 12 hours ago||||
I think you can respectfully disobey that for a demo.
w-ll 8 hours ago||
Or at the very least mention to the user that their host is set to not show animations. i too was confused
herpdyderp 10 hours ago|||
Wow I actually like it just fine with motion reduced, but it's unbearable with full motion.
CGamesPlay 5 hours ago||
I think it would be nice if the effect happened on hover as well, maybe to a lesser degree. Also, some of the controls don't appear to have any jelly in them, like the progress bar, toast, and so on. Finally, the performance on that showcase page isn't the best, and it feels like you're hijacking the scrolling somehow. But overall, it's cute. Would fit nicely as a game's UI.
tiohijazi 11 hours ago||
I dont get why people are so mad at this? Looks fun, will I ever use it? Probably not, but it looks fun
snitty 7 hours ago||
A single function button should not behave differently based on where on the button you click it.

EDIT: It's also WILDLY inconsistent. Click and drag on a button and the shape doesn't change. Click and drag on an on/off and the deformation follows the mouse. Merely click an on/off and the deformation does not follow the the little circle thingy, or bear any relation to the action of the button.

Some of the things are inoffensive, spinner dots, progress bars, accordion menus. But basically anything that deforms on click related to where you click are nonsense.

EDIT 2: The buttons in the demo area apparently do have distortion that follows the mouse, but on the left side they don't? For me this is just a lot of bafflingly inconsistent gloss that makes me wonder what's going on or why one thing behaves differently than others, and what that means for actual functionality. Rather than just interacting with the UI.

madebysnacks 10 hours ago|||
Agreed. This is the liquid glass interaction the world deserved
OsrsNeedsf2P 11 hours ago|||
We're porting our electron app to it as we speak
zuzululu 5 hours ago||
i think on HN you tend to get overly critical non-useful signals

very important to filter out and choose who you engage with

DonsDiscountGas 11 hours ago|
Okay I know this is gonna sound rude but who in the world would want form controls that behave this way?
baldvinmar 7 hours ago||
Sometimes we built for the pure joy of making. Practicality is a bonus.
nomel 3 hours ago|||
Most pages aren't meant to be 100% utilitarian. Most are meant to be little bits of art, that faces a user, that the user will enjoy interacting with.
MarvinYork 11 hours ago|||
Me.
robofanatic 9 hours ago||
candy store, ice-cream place, kid's website?
More comments...