Skip to content

ImageSegmenter (Web, GPU delegate): GL handle tables grow unbounded during continuous segmentForVideo, degrading long sessions #6352

Open

Description

@Ryosuke-Kimoto

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

macOS 15 (Chromium-based browsers)

Browser and version if the issue happens on browser

Chrome 152

Programming Language and version

JavaScript / TypeScript

MediaPipe version

@mediapipe/tasks-vision 1.0.1 (latest stable as of 2026-08-30; wasm assets from the npm package, hash-verified)

Task name (e.g. Image classification, Gesture recognition etc.)

ImageSegmenter (selfie_segmenter.tflite), runningMode: "VIDEO", delegate: "GPU", outputConfidenceMasks: true

Describe the actual behavior

When segmentForVideo() is called continuously (~24fps) in a long-running video call (background replacement use case), memory grows without bound. Measured over a 75-minute session, via V8 heap snapshots and retainer analysis:

  • The Emscripten GL handle tables (GL.framebuffers, GL.textures, GL.syncs) inside vision_wasm_internal.js grow to 11.19 MB each (~1.4M slots per array). The retainer chain goes through the setWindowedCanvasSize closure scope of the wasm module.
  • Renderer process RSS grows monotonically at ~1.2 MB/min, while a control tab without the segmenter stays flat.
  • After roughly 60 minutes, GC pauses / long tasks grow enough that users notice the page becoming sluggish (this matched a real-world user report that triggered our investigation).

Reproduced with both API styles at the same rate (~0.5 MB per handle table per minute):

  • return-value style const result = segmentForVideo(video, ts) with mask.close() called every frame
  • callback style segmentForVideo(video, ts, callback) without retaining the result

Additional observations:

  • delegate: "CPU" does not exhibit the growth (but halves our frame rate, so it is not a viable workaround).
  • Recreating the ImageSegmenter and calling close() on the old instance resets the tables — this is our current mitigation (recreate every 5 minutes).

I have not determined whether the underlying WebGL objects are actually left undeleted or whether they are deleted but the handle IDs are never recycled (so only the JS-side tables grow); either way the unbounded growth originates inside the task's GPU-delegate path and degrades multi-hour sessions.

Describe the expected behaviour

GL handle tables / per-frame WebGL resources should stay bounded during continuous segmentForVideo use, so long video sessions do not degrade.

Standalone code/steps to reproduce the issue

const fileset = await FilesetResolver.forVisionTasks(wasmPath);
const segmenter = await ImageSegmenter.createFromOptions(fileset, {
  baseOptions: { modelAssetPath: "selfie_segmenter.tflite", delegate: "GPU" },
  runningMode: "VIDEO",
  outputConfidenceMasks: true,
});
const render = () => {
  segmenter.segmentForVideo(videoEl, performance.now(), (result) => {
    // read result.confidenceMasks[0], composite onto a canvas, retain nothing
  });
  videoEl.requestVideoFrameCallback(render);
};
render();
// Take a Chrome heap snapshot after 10+ minutes: three "(object elements)"
// arrays retained via GL.framebuffers / GL.textures / GL.syncs grow ~0.5 MB/min each.

Other info / Complete Logs

Happy to share the heap-snapshot analysis scripts and raw retainer chains if useful.

Activity

  1. added
    task:image segmentationIssues related to image segmentation: Locate objects and create image masks with labels
    on Sep 1, 2026
  2. akashvverma1995 commented on Sep 1, 2026

    @akashvverma1995

    Hi @Ryosuke-Kimoto,

    Thank you for bringing this issue to our attention. We will look into it and get back to you with an update as soon as possible.

  3. akashvverma1995 commented on Sep 22, 2026

    @akashvverma1995

    Hi @Ryosuke-Kimoto

    It would be very helpful if you could share your heap-snapshot analysis scripts or logs so we can take a deeper look.

    Immediate Workaround:

    Could you try explicitly calling .close() on the mask object before your callback ends? This forces the native WebGL texture to free immediately.

    Here is how you can update your code to test this:

    segmenter.segmentForVideo(videoEl, performance.now(), (result) => {
      if (result.confidenceMasks && result.confidenceMasks.length > 0) {
        const mask = result.confidenceMasks[0];
        
        // ... draw/composite the mask onto your canvas ...
        
        // Explicitly free the native WebGL texture immediately
        mask.close(); 
      }
    });
    

    Please give this workaround a try and let us know if it stops the memory growth on your end!

  4. github-actions commented on Sep 30, 2026

    @github-actions

    This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

  5. Ryosuke-Kimoto commented on Oct 3, 2026

    @Ryosuke-Kimoto
    Author

    Thanks for the suggestion! I tested the workaround today — unfortunately explicit mask.close() inside the callback makes no difference.

    A/B measurement (same build, only difference is the mask.close() call)

    Method: headless Chrome drives segmentForVideo at ~24fps (callback style, GPU delegate, tasks-vision 1.0.1 — still the latest on npm as of today). Two V8 heap snapshots are taken via CDP (after a 30s warmup, then 3 minutes later), and I measure the growth of large (object elements) backing stores, which the retainer analysis below identifies as the Emscripten GL handle tables.

    Variant Growth of GL handle tables (3 min)
    callback, no explicit close +0.58 MB
    callback + mask.close() before callback returns (your suggestion) +0.58 MB (identical)

    For reference, our original implementation used the return-value style (const result = segmentForVideo(video, ts)) and already called mask.close() every frame — it leaked at the same per-call rate. So the growth appears to happen inside the task's GPU-delegate path during inference itself, regardless of the mask object's lifecycle on the JS side.

    The tables never shrink; growth is strictly monotonic until the ImageSegmenter instance is close()d entirely (recreating the instance resets the tables — that's our current production mitigation, recreate every 5 minutes).

    Retainer chains (from a Chrome heap snapshot after a 60-min session; tables at 11.19 MB each)

    Context/scope → Object --[setWindowedCanvasSize]--> closure:setWindowedCanvasSize
      --[context]--> Context/scope --> Object --[framebuffers]--> Array --[elements]--> (object elements)  11.19 MB
      (identical chains for --[syncs]--> and --[textures]-->, 11.19 MB each)
    

    i.e. GL.framebuffers / GL.syncs / GL.textures in vision_wasm_internal.js.

    Analysis scripts

    As requested, the two scripts I used are attached below. Both operate on plain .heapsnapshot files (saved from Chrome DevTools or CDP HeapProfiler.takeHeapSnapshot); nothing app-specific is needed to reproduce — any page driving segmentForVideo at video rate for a few minutes shows the growth.

    heap-diff.mjs — flat aggregation by node type/name (usage: node heap-diff.mjs before.heapsnapshot after.heapsnapshot out.md)
    import fs from 'node:fs';
    
    function loadSnapshot(path) {
      const raw = fs.readFileSync(path, 'utf8');
      const data = JSON.parse(raw);
      const meta = data.snapshot.meta;
      const nodeFields = meta.node_fields; // e.g. ["type","name","id","self_size","edge_count","trace_node_id","detachedness"]
      const nodeTypes = meta.node_types[0]; // array of type strings for "type" field
      const nodes = data.nodes;
      const strings = data.strings;
      const nodeFieldCount = nodeFields.length;
    
      const typeIdx = nodeFields.indexOf('type');
      const nameIdx = nodeFields.indexOf('name');
      const selfSizeIdx = nodeFields.indexOf('self_size');
    
      const agg = new Map(); // key: "type:name" -> {count, selfSize}
    
      const nodeCount = nodes.length / nodeFieldCount;
      for (let i = 0; i < nodeCount; i++) {
        const base = i * nodeFieldCount;
        const typeVal = nodes[base + typeIdx];
        const nameVal = nodes[base + nameIdx];
        const selfSize = nodes[base + selfSizeIdx];
    
        const typeStr = typeof nodeTypes[typeVal] === 'string' ? nodeTypes[typeVal] : String(typeVal);
        const nameStr = strings[nameVal] !== undefined ? strings[nameVal] : String(nameVal);
    
        const key = `${typeStr}::${nameStr}`;
        let entry = agg.get(key);
        if (!entry) {
          entry = { type: typeStr, name: nameStr, count: 0, selfSize: 0 };
          agg.set(key, entry);
        }
        entry.count += 1;
        entry.selfSize += selfSize;
      }
    
      return { agg, nodeCount, meta: { nodeFields, nodeTypes } };
    }
    
    function fmtBytes(n) {
      const sign = n < 0 ? '-' : '';
      n = Math.abs(n);
      if (n > 1024 * 1024) return `${sign}${(n / (1024 * 1024)).toFixed(2)} MB`;
      if (n > 1024) return `${sign}${(n / 1024).toFixed(1)} KB`;
      return `${sign}${n} B`;
    }
    
    const [, , baselinePath, t60Path, outPath] = process.argv;
    
    console.error('Loading baseline...');
    const base = loadSnapshot(baselinePath);
    console.error(`baseline nodes: ${base.nodeCount}`);
    
    console.error('Loading t60...');
    const t60 = loadSnapshot(t60Path);
    console.error(`t60 nodes: ${t60.nodeCount}`);
    
    // diff
    const allKeys = new Set([...base.agg.keys(), ...t60.agg.keys()]);
    const diffs = [];
    for (const key of allKeys) {
      const b = base.agg.get(key) || { type: key.split('::')[0], name: key.split('::').slice(1).join('::'), count: 0, selfSize: 0 };
      const t = t60.agg.get(key) || { type: key.split('::')[0], name: key.split('::').slice(1).join('::'), count: 0, selfSize: 0 };
      diffs.push({
        type: t.type || b.type,
        name: t.name || b.name,
        baseCount: b.count,
        t60Count: t.count,
        countDelta: t.count - b.count,
        baseSelfSize: b.selfSize,
        t60SelfSize: t.selfSize,
        selfSizeDelta: t.selfSize - b.selfSize,
      });
    }
    
    const bySelfSizeDelta = [...diffs].sort((a, b) => b.selfSizeDelta - a.selfSizeDelta).slice(0, 30);
    const byCountDelta = [...diffs].sort((a, b) => b.countDelta - a.countDelta).slice(0, 30);
    
    const totalBaseSelfSize = [...base.agg.values()].reduce((s, e) => s + e.selfSize, 0);
    const totalT60SelfSize = [...t60.agg.values()].reduce((s, e) => s + e.selfSize, 0);
    
    let md = '';
    md += '# Heap Diff: peerA baseline(0min) vs t60(60min) — Issue #18\n\n';
    md += `- baseline: ${baselinePath} (nodes=${base.nodeCount}, total self_size=${fmtBytes(totalBaseSelfSize)})\n`;
    md += `- t60: ${t60Path} (nodes=${t60.nodeCount}, total self_size=${fmtBytes(totalT60SelfSize)})\n`;
    md += `- node count delta: ${t60.nodeCount - base.nodeCount}\n`;
    md += `- total self_size delta: ${fmtBytes(totalT60SelfSize - totalBaseSelfSize)}\n\n`;
    
    md += '## Top 30 by self_size delta (t60 - baseline)\n\n';
    md += '| type | name | base count | t60 count | count Δ | base selfSize | t60 selfSize | selfSize Δ |\n';
    md += '|---|---|---:|---:|---:|---:|---:|---:|\n';
    for (const d of bySelfSizeDelta) {
      md += `| ${d.type} | ${d.name.replace(/\|/g, '\\|').slice(0,80)} | ${d.baseCount} | ${d.t60Count} | ${d.countDelta} | ${fmtBytes(d.baseSelfSize)} | ${fmtBytes(d.t60SelfSize)} | ${fmtBytes(d.selfSizeDelta)} |\n`;
    }
    
    md += '\n## Top 30 by count delta (t60 - baseline)\n\n';
    md += '| type | name | base count | t60 count | count Δ | base selfSize | t60 selfSize | selfSize Δ |\n';
    md += '|---|---|---:|---:|---:|---:|---:|---:|\n';
    for (const d of byCountDelta) {
      md += `| ${d.type} | ${d.name.replace(/\|/g, '\\|').slice(0,80)} | ${d.baseCount} | ${d.t60Count} | ${d.countDelta} | ${fmtBytes(d.baseSelfSize)} | ${fmtBytes(d.t60SelfSize)} | ${fmtBytes(d.selfSizeDelta)} |\n`;
    }
    
    fs.writeFileSync(outPath, md, 'utf8');
    console.error('Wrote', outPath);
    heap-retainers.mjs — retainer-chain walker for large arrays (usage: node heap-retainers.mjs snapshot.heapsnapshot out.md)
    import fs from 'node:fs';
    
    const [, , snapshotPath, outPath] = process.argv;
    if (!snapshotPath) {
      console.error('usage: node heap-retainers.mjs <snapshot.heapsnapshot> [out.md]');
      process.exit(1);
    }
    
    console.error('Reading file...');
    const raw = fs.readFileSync(snapshotPath, 'utf8');
    console.error('Parsing JSON...');
    const data = JSON.parse(raw);
    
    const meta = data.snapshot.meta;
    const nodeFields = meta.node_fields; // ["type","name","id","self_size","edge_count","detachedness"]
    const nodeTypes = meta.node_types[0];
    const edgeFields = meta.edge_fields; // ["type","name_or_index","to_node"]
    const edgeTypes = meta.edge_types[0]; // ["context","element","property","internal","hidden","shortcut","weak"]
    const strings = data.strings;
    
    const NF = nodeFields.length;
    const EF = edgeFields.length;
    
    const nTypeIdx = nodeFields.indexOf('type');
    const nNameIdx = nodeFields.indexOf('name');
    const nIdIdx = nodeFields.indexOf('id');
    const nSelfSizeIdx = nodeFields.indexOf('self_size');
    const nEdgeCountIdx = nodeFields.indexOf('edge_count');
    
    const eTypeIdx = edgeFields.indexOf('type');
    const eNameOrIndexIdx = edgeFields.indexOf('name_or_index');
    const eToNodeIdx = edgeFields.indexOf('to_node');
    
    const nodes = data.nodes;
    const edges = data.edges;
    const nodeCount = nodes.length / NF;
    const edgeCount = edges.length / EF;
    console.error(`nodeCount=${nodeCount} edgeCount=${edgeCount}`);
    
    // Build per-node edge start offsets (in edges array units, i.e. edge index * EF)
    // edges are laid out sequentially: node0's edges, node1's edges, ...
    const edgeStartForNode = new Uint32Array(nodeCount + 1); // edge index (not *EF) where node's edges start
    {
      let edgeCursor = 0; // edge index
      for (let i = 0; i < nodeCount; i++) {
        edgeStartForNode[i] = edgeCursor;
        const ec = nodes[i * NF + nEdgeCountIdx];
        edgeCursor += ec;
      }
      edgeStartForNode[nodeCount] = edgeCursor;
    }
    
    function nodeName(i) {
      const nameVal = nodes[i * NF + nNameIdx];
      return strings[nameVal] !== undefined ? strings[nameVal] : String(nameVal);
    }
    function nodeType(i) {
      const t = nodes[i * NF + nTypeIdx];
      return typeof nodeTypes[t] === 'string' ? nodeTypes[t] : String(t);
    }
    function nodeSelfSize(i) {
      return nodes[i * NF + nSelfSizeIdx];
    }
    function nodeId(i) {
      return nodes[i * NF + nIdIdx];
    }
    
    // Build reverse edge table: for each target node index, list of {fromNodeIdx, edgeType, edgeNameOrIndex}
    // This is memory heavy (edgeCount ~ 6.8M). Use typed arrays for compactness.
    console.error('Building reverse edge index...');
    
    // First pass: count incoming edges per node
    const inCount = new Uint32Array(nodeCount);
    for (let ni = 0; ni < nodeCount; ni++) {
      const startE = edgeStartForNode[ni];
      const endE = edgeStartForNode[ni + 1];
      for (let ei = startE; ei < endE; ei++) {
        const base = ei * EF;
        const toNodeRaw = edges[base + eToNodeIdx]; // this is node index * NF (offset into nodes array)
        const toNodeIdx = toNodeRaw / NF;
        inCount[toNodeIdx]++;
      }
    }
    
    const inStart = new Uint32Array(nodeCount + 1);
    {
      let acc = 0;
      for (let i = 0; i < nodeCount; i++) {
        inStart[i] = acc;
        acc += inCount[i];
      }
      inStart[nodeCount] = acc;
    }
    console.error(`total incoming edge slots=${inStart[nodeCount]}`);
    
    const inFromNode = new Uint32Array(inStart[nodeCount]);
    const inEdgeType = new Uint8Array(inStart[nodeCount]);
    const inEdgeNameOrIndex = new Int32Array(inStart[nodeCount]);
    const fillCursor = new Uint32Array(nodeCount); // per-node fill offset
    
    for (let ni = 0; ni < nodeCount; ni++) {
      const startE = edgeStartForNode[ni];
      const endE = edgeStartForNode[ni + 1];
      for (let ei = startE; ei < endE; ei++) {
        const base = ei * EF;
        const toNodeRaw = edges[base + eToNodeIdx];
        const toNodeIdx = toNodeRaw / NF;
        const slot = inStart[toNodeIdx] + fillCursor[toNodeIdx];
        fillCursor[toNodeIdx]++;
        inFromNode[slot] = ni;
        inEdgeType[slot] = edges[base + eTypeIdx];
        inEdgeNameOrIndex[slot] = edges[base + eNameOrIndexIdx];
      }
    }
    
    console.error('Reverse index built.');
    
    function edgeLabel(edgeTypeVal, nameOrIndex) {
      const etype = typeof edgeTypes[edgeTypeVal] === 'string' ? edgeTypes[edgeTypeVal] : String(edgeTypeVal);
      if (etype === 'element' || etype === 'hidden' || etype === 'context') {
        // name_or_index is a number (array index or context slot)
        return { etype, label: `[${nameOrIndex}]` };
      }
      // property / internal / shortcut / weak -> name_or_index is a string table index
      const nameStr = strings[nameOrIndex] !== undefined ? strings[nameOrIndex] : String(nameOrIndex);
      return { etype, label: nameStr };
    }
    
    // Find biggest array-ish nodes by self_size
    console.error('Scanning for large array nodes...');
    const THRESHOLD = 500 * 1024; // 500KB
    const bigArrays = [];
    for (let i = 0; i < nodeCount; i++) {
      const t = nodeType(i);
      const selfSize = nodeSelfSize(i);
      if (selfSize < THRESHOLD) continue;
      const name = nodeName(i);
      if (t === 'array' || name === '(object elements)' || name.includes('elements')) {
        bigArrays.push({ idx: i, type: t, name, selfSize, id: nodeId(i) });
      }
    }
    bigArrays.sort((a, b) => b.selfSize - a.selfSize);
    console.error(`Found ${bigArrays.length} array-ish nodes >500KB self_size`);
    
    function fmtBytes(n) {
      const sign = n < 0 ? '-' : '';
      n = Math.abs(n);
      if (n > 1024 * 1024) return `${sign}${(n / (1024 * 1024)).toFixed(2)} MB`;
      if (n > 1024) return `${sign}${(n / 1024).toFixed(1)} KB`;
      return `${sign}${n} B`;
    }
    
    // For a given node index, walk retainer chain up to maxDepth, at each step pick the
    // "most interesting" incoming edge (prefer property/internal edges with real object owners;
    // among candidates pick the one whose from-node has largest retained-ish self_size, or just first).
    // We'll do a simple heuristic: at each level, list ALL distinct retainers (up to a few), and
    // choose a primary path by preferring edges of type 'property' or 'internal' with a from-node
    // that is not itself another "(object elements)"/array of the same family when possible,
    // and prefer 'object' type nodes (real JS objects) as the more informative anchors.
    
    function describeNode(i) {
      const t = nodeType(i);
      const name = nodeName(i);
      return { idx: i, type: t, name };
    }
    
    function getIncomingEdges(nodeIdx) {
      const s = inStart[nodeIdx];
      const e = inStart[nodeIdx + 1];
      const list = [];
      for (let k = s; k < e; k++) {
        const fromNode = inFromNode[k];
        const et = inEdgeType[k];
        const noi = inEdgeNameOrIndex[k];
        const { etype, label } = edgeLabel(et, noi);
        list.push({ fromNode, edgeType: etype, label });
      }
      return list;
    }
    
    function buildChain(startIdx, maxDepth = 5) {
      // returns array of steps: [{node: {type,name,idx}, viaEdge: label, edgeType}, ...] from root-most to the array
      // We do BFS-ish greedy walk: at current node, find incoming edges, pick "best" one, recurse.
      const chainNodes = [describeNode(startIdx)];
      const chainEdges = []; // edge used to go from chainNodes[i] to chainNodes[i+1] (parent->child direction edge label)
      let current = startIdx;
      const visited = new Set([startIdx]);
      const allRetainersAtEachLevel = [];
    
      for (let depth = 0; depth < maxDepth; depth++) {
        const incoming = getIncomingEdges(current);
        allRetainersAtEachLevel.push(incoming.length);
        if (incoming.length === 0) break;
    
        // Filter out self-referential / visited-already-in-chain to avoid cycles
        const candidates = incoming.filter((e) => !visited.has(e.fromNode));
        const pool = candidates.length > 0 ? candidates : incoming;
    
        // Scoring: prefer property/internal edges (named, informative) over element/context edges;
        // prefer from-node type 'object'/'closure'/'synthetic' over 'array' (keep walking past intermediate arrays);
        // among ties, prefer the one whose from-node name looks like a recognizable constructor/global.
        function score(e) {
          let s = 0;
          if (e.edgeType === 'property') s += 30;
          else if (e.edgeType === 'internal') s += 20;
          else if (e.edgeType === 'shortcut') s += 15;
          else if (e.edgeType === 'context') s += 10;
          else if (e.edgeType === 'element') s += 5;
          else if (e.edgeType === 'hidden') s += 1;
          const ft = nodeType(e.fromNode);
          if (ft === 'object') s += 10;
          else if (ft === 'closure') s += 8;
          else if (ft === 'synthetic') s += 6;
          else if (ft === 'native') s += 4;
          else if (ft === 'array') s += 1;
          // prefer GC roots / global-ish names
          const fn = nodeName(e.fromNode);
          if (fn === 'Window' || fn.includes('Window') || fn === 'global') s += 20;
          return s;
        }
        pool.sort((a, b) => score(b) - score(a));
        const chosen = pool[0];
    
        chainEdges.push(chosen.edgeType === 'element' ? chosen.label : chosen.label);
        const parentDesc = describeNode(chosen.fromNode);
        chainNodes.push(parentDesc);
        visited.add(chosen.fromNode);
        current = chosen.fromNode;
    
        // Stop early if we hit a synthetic GC root-ish node
        if (parentDesc.name === '(GC roots)' || parentDesc.name === 'Window' || parentDesc.type === 'synthetic' && parentDesc.name.includes('root')) {
          break;
        }
      }
    
      return { chainNodes, chainEdges, retainerCountsAtEachLevel: allRetainersAtEachLevel };
    }
    
    const top = bigArrays.slice(0, 10);
    let md = '# Heap Retainer Analysis: peerA t60 — Issue #18\n\n';
    md += `- snapshot: ${snapshotPath}\n`;
    md += `- nodeCount=${nodeCount}, edgeCount=${edgeCount}\n`;
    md += `- threshold for "large array": self_size > ${fmtBytes(THRESHOLD)}\n`;
    md += `- total large array-ish nodes found: ${bigArrays.length}\n\n`;
    
    md += '## Top 10 largest array/elements nodes and their retainer chains\n\n';
    
    for (let rank = 0; rank < top.length; rank++) {
      const item = top[rank];
      md += `### #${rank + 1}: ${item.name} (type=${item.type}, self_size=${fmtBytes(item.selfSize)}, node_id=${item.id}, node_idx=${item.idx})\n\n`;
    
      const { chainNodes, chainEdges, retainerCountsAtEachLevel } = buildChain(item.idx, 6);
    
      // Print chain from root (last element) down to the array (first element), i.e reverse chainNodes
      const pathParts = [];
      for (let i = chainNodes.length - 1; i >= 0; i--) {
        const n = chainNodes[i];
        let part = `${n.type}:${n.name || '(anonymous)'}`;
        pathParts.push(part);
        if (i > 0) {
          const edgeLbl = chainEdges[i - 1];
          pathParts.push(`--[${edgeLbl}]-->`);
        }
      }
      md += `Chain (root -> array): ${pathParts.join(' ')}\n\n`;
      md += `Incoming-edge counts at each level (array outward): [${retainerCountsAtEachLevel.join(', ')}]\n\n`;
    
      // Also list ALL immediate retainers of the array itself (top 5), to catch multi-owner cases (e.g. shared by many objects)
      const immediate = getIncomingEdges(item.idx);
      md += `Immediate retainers of this node: ${immediate.length} total. Top few:\n\n`;
      const sampleImmediate = immediate.slice(0, 8);
      for (const e of sampleImmediate) {
        const fn = describeNode(e.fromNode);
        md += `- via [${e.edgeType}] "${e.label}" <- ${fn.type}:${fn.name || '(anonymous)'} (idx=${fn.idx})\n`;
      }
      md += '\n';
    }
    
    fs.writeFileSync(outPath || '/dev/stdout', md, 'utf8');
    console.error('Done. Wrote', outPath);

    Happy to run further experiments if it helps — this is easy for me to reproduce.

  6. akashvverma1995 commented on Oct 7, 2026

    @akashvverma1995

    Hi @Ryosuke-Kimoto

    Thank you for providing the details. I'll look into this and get back to you with an updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

os:macOSIssues on MacOSplatform:javascriptMediaPipe Javascript issuestask:image segmentationIssues related to image segmentation: Locate objects and create image masks with labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions