Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

The GPU that says yes and does nothing: debugging real-time hair segmentation on mid-range Android

We build a virtual mirror for hair salons : a tablet camera feed where the customer's hair changes colour in real time while they move their head. Two constraints shaped every decision. The first is privacy: no frame ever leaves the device. Everything runs locally — the model, the fonts, the runtime — with no CDN dependency, because a CDN request would both break offline use and leak the salon's…

We created a virtual mirror for hair salons using a tablet camera feed, where the customer's hair changes color in real-time as they move their head. Two constraints shaped every decision: privacy (no frame leaves the device) and hardware (salons don't buy flagship tablets). The team optimized the process by measuring frame rates on real Android devices using diagnostic tools. A Pixel 8 Pro ran at 9 fps while a Samsung A56 (Exynos 1580, Mali GPU) showed no color at all.

The issue turned out to be the MediaPipe's ImageSegmenter with GPU delegate, which ran in 5 ms and returned zero hair pixels. The fallback to CPU-only triggered on exceptions, but there were no exceptions. The team discovered that a delegate that constructed successfully might not work, and it's crucial to check the output, not just the exit code. They implemented a fallback that rebuilds the engine on CPU after five consecutive empty masks.

The team also found that the per-pixel JavaScript loop was a significant contributor to the frame budget. They moved the recolouring into a fragment shader, reducing the time from 66 ms to 0. They decoupled the mask from the draw, drawing the video on all frames using the most recent mask. This change fixed the A56, and the Pixel 8 Pro went from 9 fps to 15 fps.

They also shared the WebGL context with MediaPipe, eliminating the CPU round trip for the mask. Finally, they switched to a specialised model, reducing the APK size and improving performance.

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

Laravel Concurrency: Atomicity, Transactions, and Locking

Two customers try to purchase a product at exactly the same time. If the application isn't designed for concurrency, both requests might read stock = 1 and both complete the purchase.

  • Atomicity ensures database operations are treated as a single indivisible unit.
  • Laravel's DB::transaction() method can create atomic operations.
  • Transactions are finalized with COMMIT or undone with ROLLBACK.

MCP Servers for Figma, Jira, GitLab and Playwright

People typing "figma mcp server" or "jira mcp server" into search are usually after the same thing: a connection between a tool they use every day and the AI assistant they already work in.

  • MCP servers connect AI assistants with data sources like Figma, Jira, GitLab, and Playwright.
  • Figma offers local and remote MCP server options, with remote recommended for data protection.
  • GitLab's MCP server is built-in since version 18.3, requiring GitLab Duo and access to MCP.

More from Monday 17 August →