# WebGL Mobile Crash Fix

> Fix three.js and WebGL apps that crash or reload on phones, with tested drop-in TypeScript modules.

WebGL Mobile Crash Fix is a paid AI agent skill on Agensi by Michal Burgermeister, in Mobile Development. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $12 (one-time purchase)
- Creator: [Michal Burgermeister](https://www.agensi.io/creators/michal-burgermeister)
- Category: [Mobile Development](https://www.agensi.io/skills/mobile-development)
- Version: 1.0
- Last updated: 2026-10-16
- Security: scan passed (2026-10-16); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/webgl-mobile-crash-fix
- Tags: mobile, web-design, webgl, pwa, typescript, performance, ios-safari

## About this skill

A web app running perfectly on a workstation but crashing on an iPad or Android phone is a classic memory and resource management failure. This skill provides the diagnostic logic and drop-in TypeScript modules to stop WebGL, Three.js, and heavy PWA graphics from triggering browser reloads or "Aw, Snap" errors on mobile devices. It replaces generic rendering with a tiered resource strategy that respects hardware limits before the crash happens.

### What it does
- **Device tiering** Categorizes hardware based on memory and cores to cap texture sizes, DPR, and object counts.
- **Crash guarding** Detects repeated unclean boots via `localStorage` and automatically demotes to a "lite" mode.
- **Reload protection** Limits automated recovery reloads to one per minute to prevent Android process loops.
- **PWA stability** Reconfigures service worker updates to prevent disruptive mid-session page reloads.
- **Context management** Implements required handlers for WebGL context loss and restoration to prevent black screens.

### How it works
1. **Analyze crash context** Identify if the failure occurs at initial boot, during heavy mode transitions, or due to PWA service worker conflicts.
2. **Implement tiering** Integrate `deviceTier.ts` to scale graphics quality based on `navigator.deviceMemory` and `hardwareConcurrency`.
3. **Deploy guards** Add `crashGuard.ts` and `reloadGuard.ts` to the app entry point to handle silent OS-level renderer kills.
4. **Verify bundle** Use the provided shell script to confirm the fix is actually present in the live CDN bundle and lazy-loaded chunks.

### Frameworks & tools
TypeScript, Three.js, React-Three-Fiber, Babylon.js, Globe.gl, Vite-plugin-PWA, Vitest, and WebGL.

### Why this beats prompting it yourself
Generic AI prompts often suggest generic optimizations that don't account for how Safari handles GPU memory or how PWAs trigger reloads. This skill provides tested, zero-dependency logic specifically designed for the edge cases of mobile browser resource limits and service worker lifecycles.

### Use cases
- **Fixing mobile crashes** Stop 3D maps or product configurators from crashing on iPhones.
- **PWA deployment** Prevent the "double-reload" bug when a new service worker version is detected.
- **Low-end support** Automatically scale down assets for budget Android devices without affecting desktop users.

### Known limitations
`navigator.deviceMemory` is Chromium-only, so Safari and Firefox fall to the cautious low tier, and the tiering never puts iOS above mid tier. A single view transition that builds too much in one frame still needs staging — the skill explains how, but it is app-specific code.

## Requires

- TypeScript or JavaScript web project
- Bash
- curl
- Node.js
- Optional: Vitest
- Optional: jsdom

Bash and curl run the live-bundle checker. Vitest and jsdom only run the bundled tests.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the WebGL Mobile Crash Fix skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What specific types of mobile crashes does this skill prevent?

This skill addresses hardware-level resource exhaustion that leads to 'Aw, Snap!' errors, black screens, and the infinite reload loops often triggered by PWA service workers on iOS and Android.

### Will this work if I am using Three.js or React-Three-Fiber instead of raw WebGL?

Yes. The modules only read device capabilities and manage storage, reloads and the canvas context, so they work with three.js, react-three-fiber, Babylon.js, globe.gl or raw WebGL — you apply the returned budgets (texture size, pixel ratio, object count) in your own renderer.

### What exactly is included in the purchase?

Five drop-in TypeScript modules — deviceTier, crashGuard, reloadGuard, contextLoss and a vite-plugin-pwa service-worker helper — with 18 vitest tests, the diagnostic workflow in SKILL.md, README.md, and scripts/verify-live-bundle.sh, which checks that your fix is in the deployed bundle including lazy chunks.

### How does the skill handle the specific memory limitations of Safari on iOS?

While Safari restricts certain memory reporting APIs, this skill uses a heuristic-based tiering system specifically designed to handle iOS-specific GPU memory caps that generic tools often miss.

### How difficult is the installation process for an existing web project?

The modules are designed for zero-dependency integration; you simply import the guards at your application's entry point and wrap your rendering logic in the provided tiering function.

### Which AI agents are compatible with this skill?

Any agent that reads SKILL.md: Claude Code, Codex, Cursor, Gemini CLI, Hermes Agent and others. The modules are plain TypeScript, so they work with any build setup.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
