cocos-web-inspector-mcp 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/src/bridge.js +22 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,9 @@ The V8 inspector has no page, so native mode registers only the tools that read
|
|
|
64
64
|
- `cocos_console_messages` (with `--allow-browser-data`) reads the app process's `Cocos`-tagged logcat lines, so it includes logs from before the server attached, bounded by the device log buffer. `console.log` and `console.debug` both report as `log`; an uncaught error spans several `error` lines.
|
|
65
65
|
- Not registered: `cocos_capture_node`, `cocos_emulate_device`, `cocos_highlight_node`, `cocos_get_selection` (DOM overlays draw nothing), `cocos_analyze_batches` (the native 2D batcher runs in C++), `cocos_step_frame` (stepping from the inspector renders outside the native frame loop and crashed the app), and the network and storage tools.
|
|
66
66
|
|
|
67
|
-
The inspector accepts one session at a time, so the server connects per call; Chrome DevTools can attach between calls, and a call made while DevTools is attached fails with `CDP_UNAVAILABLE`. If calls start failing with `CDP_UNAVAILABLE` while the app runs, the adb server restarted
|
|
67
|
+
The inspector accepts one session at a time, so the server connects per call; Chrome DevTools can attach between calls, and a call made while DevTools is attached fails with `CDP_UNAVAILABLE`. If calls start failing with `CDP_UNAVAILABLE` while the app runs, the adb server restarted or the device dropped off USB, which takes the forward with it; run `adb forward` again. When a phone keeps dropping off USB (common through hubs), switch adb to Wi-Fi with `adb tcpip 5555` and `adb connect <phone-ip>:5555`, then forward and set `ANDROID_SERIAL=<phone-ip>:5555`; the endpoint stays `127.0.0.1`.
|
|
68
|
+
|
|
69
|
+
Only a build with the inspector compiled in can attach. If a game's Debug build fails, setting `USE_V8_DEBUGGER_FORCE` and `CC_DEBUG_FORCE` to `ON` in `native/engine/common/CMakeLists.txt` keeps the inspector in a release build; never ship such a build.
|
|
68
70
|
|
|
69
71
|
## Install and run
|
|
70
72
|
|
package/dist/src/bridge.js
CHANGED
|
@@ -810,11 +810,9 @@ export function inspectCocos(request) {
|
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
if (selected === node) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
displayFields[key] = typeof value === 'string' ? value.slice(0, 500) : value;
|
|
817
|
-
}
|
|
813
|
+
// Native (JSB) nodes keep these in C++ behind accessors; summary reads the same public getters the scene tree reports.
|
|
814
|
+
const { name, active, activeInHierarchy } = summary(node);
|
|
815
|
+
Object.assign(displayFields, { name, active, activeInHierarchy });
|
|
818
816
|
}
|
|
819
817
|
if (typeof cc.Sprite === 'function' && selected instanceof cc.Sprite) {
|
|
820
818
|
const frame = dataProperty(selected, '_spriteFrame');
|
|
@@ -1162,7 +1160,21 @@ export function inspectCocos(request) {
|
|
|
1162
1160
|
}
|
|
1163
1161
|
// Asset helpers read backing fields only; refCount, width, and texture getters stay untouched.
|
|
1164
1162
|
const assetName = (asset) => String(dataProperty(asset, '_name') ?? '').slice(0, 500);
|
|
1165
|
-
|
|
1163
|
+
// Native (JSB) assets keep _uuid behind a C++ accessor, which data reads skip; the asset cache is keyed by uuid, so look it up there.
|
|
1164
|
+
let cachedUuids;
|
|
1165
|
+
const assetUuid = (asset) => {
|
|
1166
|
+
const own = dataProperty(asset, '_uuid');
|
|
1167
|
+
if (typeof own === 'string' && own)
|
|
1168
|
+
return own;
|
|
1169
|
+
if (!cachedUuids) {
|
|
1170
|
+
cachedUuids = new Map();
|
|
1171
|
+
const map = dataProperty(cc.assetManager?.assets ?? {}, '_map');
|
|
1172
|
+
for (const [key, value] of Object.entries((map && typeof map === 'object' ? map : {})))
|
|
1173
|
+
if (value && typeof value === 'object')
|
|
1174
|
+
cachedUuids.set(value, key);
|
|
1175
|
+
}
|
|
1176
|
+
return cachedUuids.get(asset) ?? '';
|
|
1177
|
+
};
|
|
1166
1178
|
const gfxBytes = (texture) => {
|
|
1167
1179
|
const gfx = texture && typeof texture === 'object' ? dataProperty(texture, '_gfxTexture') : undefined;
|
|
1168
1180
|
const size = gfx && typeof gfx === 'object' ? dataProperty(gfx, '_size') : undefined;
|
|
@@ -1681,10 +1693,13 @@ export function inspectCocos(request) {
|
|
|
1681
1693
|
// Unused first, then by GPU bytes and refCount: the likeliest leaks lead.
|
|
1682
1694
|
items.sort((a, b) => Number(b.status === 'unused') - Number(a.status === 'unused') || (b.bytes ?? 0) - (a.bytes ?? 0) || b.refCount - a.refCount);
|
|
1683
1695
|
const memory = dataProperty(dataProperty(dataProperty(cc.director, '_root') ?? {}, '_device') ?? {}, '_memoryStatus');
|
|
1696
|
+
// Native (JSB) GFX textures live in C++ and expose no byte size to JS; report that instead of zeros that read as "no textures".
|
|
1697
|
+
const textureCount = Object.entries(byType).filter(([type]) => /Texture/.test(type)).reduce((sum, [, bucket]) => sum + bucket.count, 0);
|
|
1698
|
+
const bytesUnavailable = totalBytes === 0 && textureCount > 0;
|
|
1684
1699
|
return {
|
|
1685
1700
|
version,
|
|
1686
1701
|
assetCount: Math.min(total, 50_000),
|
|
1687
|
-
textureBytes: totalBytes,
|
|
1702
|
+
...(bytesUnavailable ? { textureBytes: null, unavailableMetrics: { textureBytes: 'UNSUPPORTED_PUBLIC_API' } } : { textureBytes: totalBytes }),
|
|
1688
1703
|
...(memory ? { gpuMemory: { textureBytes: Number(dataProperty(memory, 'textureSize') ?? 0), bufferBytes: Number(dataProperty(memory, 'bufferSize') ?? 0) } } : {}),
|
|
1689
1704
|
byType,
|
|
1690
1705
|
assets: items.slice(0, limit),
|