Urgent.News

What's breaking now, across thousands of outlets.

Tech

44 seconds to render a shoe: six fixes, and the biggest one was a single toDataURL call

I build a customizer for printed sneakers. You upload an artwork, it gets split across the leather panels of a shoe, and you see the result on the actual shoe before buying. The geometry is the interesting part — that's the first post and the second . This post is about the other half: it worked, and it was unusably slow. Cold load, first preview: 44 seconds . Here is what actually fixed it —…

This report covers the story of optimizing the rendering of custom printed sneakers in a customizer tool. The initial load time for a shoe preview was an unusably slow 44 seconds. The slow performance was due to the browser downloading large image files in the background, decoding them at full resolution, and then executing unnecessary work. There were six main fixes implemented to improve the rendering speed.

1. The first fix involved decoding 16 MB of images that were not visible. The code used to generate a thumbnail of each angle was generating a 1800x1800 PNG image, which is about 5.6 MB as a base64 data URL. By replacing the 1800x1800 PNG with a 256x256 JPEG image on a white background, the image size was reduced to 15 KB per angle, resulting in a 15x reduction in image size.

2. The second fix addressed the use of PNG images with alpha channels, which were not needed for the preview. The images were converted to WebP format with a quality of 84, reducing the image size from 51.4 MB to 3.0 MB while maintaining visual quality.

3. The third fix was to avoid downloading base images that were not needed for rendering. One of the angles had a 4000x4000 image that could not be mapped onto the shoe panels. By checking if a mesh was available for each angle, the unnecessary download was eliminated, saving 5 MB of data from the critical path.

4. The fourth fix involved optimizing the mask loading process. The render loop was downloading and processing 29 masks sequentially, causing significant latency. By kicking off all 29 mask loads concurrently using Promises and a Set, the process became asynchronous, significantly reducing the time taken for mask processing.

5. The fifth fix aimed to improve the user experience by preventing the main thread from being blocked during the rendering process. By adding a short delay (using setTimeout with a 0ms delay) between rendering iterations, the main thread was given time to update the UI and allow for smooth scrolling and interaction.

6. The final fix involved restructuring the rendering process to render one angle at a time, showing the progress to the user. The original process downloaded all 5 base images and masks, rendered all 5 angles, and then displayed the result. This sequential execution led to a 44-second load time. By splitting the process into two passes - downloading and processing the images in the background, and then rendering and displaying the result, the user could see the progress and interact with the tool while waiting for rendering.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Fridge Sloth 🦥: snap your fridge, get a grocery list and healthy meals, fully offline on Gemma

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady What I Built Fridge Sloth is for the moment you stand in front of the open fridge, door wide open, trying to…

  • Fridge Sloth snaps fridge photos to create grocery lists offline
  • Uses Gemma 3 AI model for food recognition and meal suggestions
  • Privacy-focused, no account or API key required for operation

Scoping a Website for a Painting Contractor, Line by Line

If you build websites for local trades, painters are a good client: they have real work to show and a clear goal, which is booked estimates. But they are easy to over-scope.

  • Website should showcase contractor's finished work to drive conversions
  • Prioritize safety and reliability elements like license, insurance, warranty
  • Estimate form takes precedence over prominent phone number

I built Nitron to turn web projects into mobile apps with npm

I built Nitron to turn web projects into mobile apps with npm You have a website built with HTML, CSS, and JavaScript. It works, it looks good, and you're happy with it.

  • Nitron simplifies converting web projects to mobile apps for Android and iOS.
  • Utilizes npm to streamline development workflow for web developers.
  • Open-source tool seeks feedback from developers interested in mobile deployment.

I Built My Entire UI With the Wrong shadcn Style. Here’s How I Fixed It

As you keep building projects, you discover surprising challenges you didn't even know existed. Have you ever tried changing the style of a shadcn project from base UI to radix UI or vice versa?, it…

  • Author encountered UI style mismatch between sub-project and main website
  • Mistakenly chose base UI style during shadcn installation

More from Saturday 24 October →