How to Fix Avatar Skin Hiding and 42-Second Browser Freezes

2026-11-28来源 dev.toEnglish

📝 Originally published (in Japanese) at forge.workstyle.tech.

TL;DR The avatar's feet disappeared inside shoes after changing the skin-hiding logic. Opening the base avatar in the browser caused a 41.7-second main-thread stall and 42.7 seconds of total long tasks. The causes were bone-based skin hiding, repeated calculations, and rebuilding all clothes during shoe adjustments.

Conclusion

Because I was hiding skin only at the bone positions, even the feet visible inside the shoes disappeared. The browser froze while calculating the skin masking and rebuilding the clothes: before the fix, a single main-thread task took 41.7 seconds, and long tasks totaled 42.7 seconds. After adjusting the skin masking area and the feet’s position inside the shoes, then caching and splitting up the calculations, the initial total time spent in long tasks dropped to 3.7 seconds.

Why Did the Feet Inside the Shoes Disappear When I Hid Skin?

At 08:08 UTC on October 10, a user pointed out: “Aren’t the feet inside the shoes gone? You can see through there, right? I mean the part from the instep onward.” After I rebuilt the process for hiding skin beneath clothing, the feet that should have been visible inside the shoes disappeared too.

When I investigated, I found a rule that hid skin based on the toe bones: toes ≥ 0.3 + sole. Because it used bone positions to determine what to hide, it also affected the feet visible inside the shoes. I tried to replace this rule, but the line that applied the new result had been commented out, so it never ran. I thought I’d changed the code, but the change wasn’t reflected in the results.

So I stopped hiding skin based only on bone conditions. Instead, I check the skin from 240 viewpoints outside the model, 0.6 m away, and hide only the surfaces that are invisible from every viewpoint. I hid 3,078/3,037 surfaces.

With the clothes on, I also checked three poses: walking, sitting, and crouching. Skin clipping was 6.7%, 5.7%, and 7.6%, respectively. In the previous version, it was 10.9%, 8.3%, and 15.6%. The percentage went down in all three poses.

How I Fixed the Toes Sinking Into the Shoe Sole

Even after fixing how much skin was hidden, another problem remained with the feet. When I tilted a foot by about 41°, the toes sank 1–2 cm below the insole. Showing the top of the foot and the toes still didn’t look right if the toes sank into the sole.

For heeled shoes only, I bent the toe bones back by 90% of the heel angle. After adjusting the foot angle, I remeasured the clipping for each pose. Deciding how much to hide and aligning the foot inside the shoe had to be checked separately.

Why Did the Browser Freeze for 42 Seconds?

At 18:55 UTC that same day, someone reported, “I opened it in the browser, but it freezes.” I measured how long the browser stalled when opening the base model. Using a headless browser (one that runs without displaying a window) and software GL, I captured a CPU profile (a record of processing time) and a long-task observer (which records lengthy operations). The main thread (responsible for tasks such as updating the screen) stalled once for 41.7 seconds, and the total long-task time was 42.7 seconds.

The breakdown showed that skin occlusion calculations took about 27 seconds. For every vertex on the feet, the app cast up to two rays from each of 240 viewpoints, repeating the calculations on every update. Rebuilding the clothes took about 8 seconds per run, and it ran twice. That was because the entire outfit was rebuilt every time the shoes were raised. Both the skin checks and the number of outfit rebuilds contributed to the freeze.

Which changes reduced the pauses?

During the fixes, after making the work asynchronous, I once measured old shoes and repeatedly added height to them, causing the character to keep rising. I fixed it on the spot. Even when you split processing into asynchronous tasks, stale values can make the results drift.

After that, I changed clothing generation to handle one item at a time, leaving a frame between items. Shoes are processed first. I cached the skin-occlusion results (saving and reusing computed results) and reduced the number of viewpoints from 240 to 64. I split the computation into a generator (a mechanism for advancing processing in small chunks) that yields about every 120 ms, and switched smoothing to a grid approximation (approximating values on a grid). I saved outfit-matching results in IndexedDB (a way to store data in the browser).

What Changed in Display Time and Long Tasks After the Fix

After the fix, I measured the initial load, the second load, switching outfits, and the unclothed base model separately. On the initial load, the first render appeared after 1.4 seconds, and the full outfit was on after 10.1 seconds. There were seven long tasks over 200 ms, with a maximum of 658 ms and a total of 3.7 seconds.

On the second load, the first render appeared after 1.5 seconds, and the outfit was fully loaded after 6.9 seconds. There were two long tasks, with a maximum of 559 ms. When switching outfits, the first render appeared after 1.6 seconds, and the outfit was fully loaded after 6.4 seconds. The longest task was 556 ms. The unclothed base model rendered after 1.5 seconds and was fully displayed after 2.0 seconds, with a long task of about 690 ms.

Compared with the 42.7 seconds before the fix, the time spent blocking the browser dropped substantially. Even so, on the initial load, each clothing item still blocks the browser for 0.5–0.65 seconds. I can’t say the issue is fully resolved. For the leg issue, I checked from the camera’s viewpoint which skin areas should be hidden. For the browser blocking, I measured how long the processing took and what was repeated on each update. Neither a visual bug nor a wait time can be considered fixed just because a change was made. I measured each pose and each process, checked the results, and only then moved on to the next fix.

Key takeaways

  • Check skin clipping while walking, sitting, and crouching with clothes on.
  • Check whether the toes sink below the insole when the foot is tilted.
  • Measure initial load, second load, switching, and the unclothed avatar separately.
  • Use a CPU profile and long-task observer to measure skin hiding and clothing rebuilds.

原文:https://www.a8q9.cn/en/article/how-to-fix-avatar-skin-hiding-and-42-second-browser-freezes-6c016b.html

相关文章