Fix a crash that occurred when a model returns fewer vector elements than before
PiperOrigin-RevId: 489041814
This commit is contained in:
parent
74474d859e
commit
3cdf0f6536
|
@ -406,7 +406,7 @@ export class WasmMediaPipeLib {
|
||||||
*/
|
*/
|
||||||
setVectorListener<T>(
|
setVectorListener<T>(
|
||||||
outputStreamName: string, callbackFcn: (data: T[]) => void) {
|
outputStreamName: string, callbackFcn: (data: T[]) => void) {
|
||||||
const buffer: T[] = [];
|
let buffer: T[] = [];
|
||||||
this.wasmModule.vectorListeners = this.wasmModule.vectorListeners || {};
|
this.wasmModule.vectorListeners = this.wasmModule.vectorListeners || {};
|
||||||
this.wasmModule.vectorListeners[outputStreamName] =
|
this.wasmModule.vectorListeners[outputStreamName] =
|
||||||
(data: unknown, index: number, length: number) => {
|
(data: unknown, index: number, length: number) => {
|
||||||
|
@ -419,6 +419,7 @@ export class WasmMediaPipeLib {
|
||||||
// the underlying data elements once we leave the scope of the
|
// the underlying data elements once we leave the scope of the
|
||||||
// listener.
|
// listener.
|
||||||
callbackFcn(buffer);
|
callbackFcn(buffer);
|
||||||
|
buffer = [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user