Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-performance

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Optimize draw calls: static merge, instancing, dynamic atlases and GPU morph fields. Frame budgets, on-demand rendering, AIR_E_MESH_CAPACITY, AIR_E_PIXEL_RATIO_IMPORT_ORDER.

  • 12 files
  • 84.2 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-performance

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontext.md

≈1.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Working context

Use package imports and shipped docs for an application; use source paths and repository commands only in a confirmed AIR checkout. A copied host skill is not a runtime installation.

Read the shared environment rules when locating these roots. If sibling resources are unavailable, use the installed canonical chapter and disclose the limitation. Tool declarations identify workflow capabilities; they do not authorize installation, writes, publication or any action outside the user and host scope.

Related skills

  • cocosair - routing and shared Code First constraints; reuse it if already loaded.
  • cocosair-application - game and createAirApp lifecycle, designResolution and the rest of the option plumbing; this skill owns only pixelRatioCap cost and the pause/step discipline.
  • cocosair-project-setup - which entry exposes a name and how AIR_FEATURES variants are built; this skill reads the default bundle face only.
  • cocosair-scene-graph - node activation order, layer bits and when a MeshRenderer component exists at all; this skill owns what batching does to those renderers.
  • cocosair-camera - visibility masks, camera priority and frustum culling, which keep running per node under every route below.
  • cocosair-materials-effects - effect and material authoring, including the shader side of USE_INSTANCING; this skill owns the batching decision and the draw count.
  • cocosair-primitives-mesh - Mesh structure, attributes and createPrimitiveGeometry; this skill owns Mesh.merge and the dynamic-mesh update loop.
  • cocosair-rendering - lights, shadows, render targets and pipeline reachability; shadow and target cost is not this skill.
  • cocosair-graphics-and-dom - AirUIMesh authoring and its geometry limits; this skill owns its atlas and lease behavior, and Vec3/Mat4 helpers come from cocosair-math.
  • cocosair-verification - gate and evidence-collection commands; the two performance collectors are summarized there.

Original entry guidance

The original entry wording below is an on-demand archive, not a second routing source.

Use the environment rules to locate the checkout or installed package; sibling skills are optional direct dependencies, not a recursive load list.

Cut draw calls through the three documented batching routes and the one instancing macro, keep 2D sprites batchable, and read the frame budget with the profiler singleton plus pause/step rendering.

Read references/quick-start.md when constructing the minimal example. It preserves the complete setup and teardown sequence; select the source-checkout or npm-consumer environment first.

Read references/context.md to select the owner of this step and only its directly needed dependencies. Reuse already loaded skills; this is not a recursive load list.

Original mistake navigation

Before implementing the relevant path, read its wrong/right examples in references/common-mistakes.md:

  • [HIGH] Reaching for a generic static-batch component
  • [HIGH] Expecting each node to keep its own material after batching
  • [HIGH] Using director.pause to stop rendering and setDisplayStats for stats
  • [MEDIUM] Turning dynamic atlas on mid-scene and expecting a silent win

Original metadata

Description and description_en

The two original fields contained exactly the same value, retained once here.

Drives the Cocos AIR draw-call and frame-budget surface - the only three batching routes (shared mesh across N renderers, Mesh.merge and BatchingUtility.batchStaticModel for static subtrees, utils.MeshUtils.createDynamicMesh with Mesh.updateSubMesh for per-frame geometry), instancing through the single USE_INSTANCING material define with its 1024-per-group split, dynamic atlas defaults and silent-null acceptance rules, 2D auto-batch keys on director.root.batcher2D, the profiler singleton counters behind the pipeline.profiler gate, on-demand rendering as game.pause plus game.step behind Director.EVENT_AFTER_DRAW, pixelRatioCap and the DPR import-order contract, and the recorded limits of the 50k starfield evidence. Use when draw calls equal object count, batching hundreds of cubes or sprites, hitting AIR_E_MESH_CAPACITY or AIR_E_PIXEL_RATIO_IMPORT_ORDER, enabling dynamicAtlasManager, showing the stats overlay, checking whether the loop is really paused, or cutting resolution on a slow device.

Keywords

Cocos AIR, cocosair.js, performance

References

  • batching-routes.md - the three routes with their measured draws, harness caps and AIR_E_MESH_* errors, batchStaticModel/unbatchStaticModel effects, Batcher2D batch keys and buffer sizing, UIStaticBatch inertness, measurement scope, browser-verified ids.
  • dynamic-atlas.md - the default off state and why, knob defaults with setters, silent-null acceptance rules, atlas layout and bleeding, what makes a SpriteFrame packable, texture identity and the internal descriptor-set cache, AirUIMesh texture leases and geometry capacity, verification status.
  • instancing.md - the single USE_INSTANCING macro entry, how it becomes a batching scheme and its silent downgrade, per-instance attributes the builtin effects declare, grouping keys, capacity and split draws, setInstancedAttribute timing, what instancing does not buy, the three capability layers, the stale manual sentence.
  • profiles.md - the profiler/Profiler surface with every counter and its source, color setters and teardown, the pipeline.profiler render gate, the deprecated setDisplayStats forwarders, game.pause/step/resume and the fixed dt, the first-frame trap, pixelRatioCap and the DPR chain, the 50k evidence boundary, the two tools-side collectors.

Canonical docs

  • docs/manual/batching-recipes.md - open for the three-route table, the fixed measurement conditions and the p95 draw and CPU numbers behind every batching claim.
  • docs/manual/optimize-lots-of-objects.md - open for the 100-cube BatchingUtility contract probe, the batch/unbatch scene-graph dumps and the static-only usage constraints.
  • docs/manual/rendering-on-demand.md - open for the PARTIAL status, the pause/step sequence in source order and the two measured traps with their timings.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "draw calls equal the object count",
  "batch many static meshes or UI sprites; createAirInstanceBatch/createAirMorphField point/voxel",
  "measure actual draw counts and frame budget",
  "stop rendering until the next requested frame",
  "high pixel density makes the device too slow"
]
owns
[
  "batching",
  "instancing",
  "dynamic-atlas",
  "profiler",
  "on-demand-rendering",
  "pixel-ratio"
]
not_for
[
  "procedural geometry authoring -> cocosair-primitives-mesh",
  "startup admission and app lifecycle -> cocosair-application",
  "material property types -> cocosair-materials-effects"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "选择静态合批、动态图集和实例化,并检查性能统计、剔除和按需渲染。用于大量对象、动画或绘制性能优化。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-performance