{"record":{"id":"39208633a5fa986a","repo":"jitsi/jitsi-meet","slug":"failed-to-create-wasm-input-memory-buffer","errorCode":null,"errorMessage":"Failed to create wasm input memory buffer!","messagePattern":"Failed to create wasm input memory buffer!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"react/features/stream-effects/rnnoise/RnnoiseProcessor.ts","lineNumber":78,"sourceCode":"    /**\n     * Constructor.\n     *\n     * @class\n     * @param {Object} wasmInterface - WebAssembly module interface that exposes rnnoise functionality.\n     */\n    constructor(wasmInterface: IRnnoiseModule) {\n        // Considering that we deal with dynamic allocated memory employ exception safety strong guarantee\n        // i.e. in case of exception there are no side effects.\n        try {\n            this._wasmInterface = wasmInterface;\n\n            // For VAD score purposes only allocate the buffers once and reuse them\n            this._wasmPcmInput = this._wasmInterface._malloc(RNNOISE_BUFFER_SIZE);\n\n            this._wasmPcmInputF32Index = this._wasmPcmInput >> 2;\n\n            if (!this._wasmPcmInput) {\n                throw Error('Failed to create wasm input memory buffer!');\n            }\n\n            this._context = this._wasmInterface._rnnoise_create();\n        } catch (error) {\n            // release can be called even if not all the components were initialized.\n            this.destroy();\n            throw error;\n        }\n    }\n\n    /**\n     * Release resources associated with the wasm context. If something goes downhill here\n     * i.e. Exception is thrown, there is nothing much we can do.\n     *\n     * @returns {void}\n     */\n    _releaseWasmResources(): void {\n        // For VAD score purposes only allocate the buffers once and reuse them","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/jitsi/jitsi-meet/blob/98de6219cc7ddbe07ace9fde045aff90a242ba01/react/features/stream-effects/rnnoise/RnnoiseProcessor.ts#L60-L96","documentation":"RnnoiseProcessor's constructor allocates a wasm heap buffer via _malloc(RNNOISE_BUFFER_SIZE) for the PCM input and throws if the allocation returns 0 (a null pointer in wasm heap terms). A zero return from emscripten's _malloc means the wasm module's heap could not satisfy the allocation — typically because the module wasn't fully initialized, was compiled without ALLOW_MEMORY_GROWTH, or is corrupt/mismatched with the JS glue code.","triggerScenarios":"Instantiating RnnoiseProcessor before the rnnoise wasm module finished instantiating (calling _malloc on an unbuilt module); a wasm build without ALLOW_MEMORY_Growth where initial memory (16MB default) is exhausted; mismatched rnnoise.wasm and rnnoise_processor.js versions after a partial upgrade; memory pressure in long-running sessions after repeated create/destroy cycles leaking heap (destroy not freeing).","commonSituations":"Bundling issues where the .wasm asset is stale or truncated (webpack copy plugin misconfiguration), Safari/older browsers with wasm memory limits, enabling the noise suppression effect too early in app startup, or a version bump of the rnnoise package without rebuilding assets.","solutions":["Verify the rnnoise wasm assets are the matching pair shipped with the package version and are correctly served (network tab: rnnoise.wasm loads 200 with expected byte size); rebuild/clean if partially upgraded.","Only construct RnnoiseProcessor after the effect's init/wasm load promise resolves; don't instantiate during module load.","Ensure destroy() is always called on failed/old processors so _free releases the malloc'd buffer and the rnnoise state, avoiding heap exhaustion across sessions.","Re-enable ALLOW_MEMORY_GROWTH (or raise INITIAL_MEMORY) if building a custom rnnoise wasm."],"exampleFix":"// before\nconst processor = new RnnoiseProcessor(wasmInterface); // may throw 'Failed to create wasm input memory buffer!'\n\n// after\nlet processor: RnnoiseProcessor | null = null;\ntry {\n    processor = new RnnoiseProcessor(wasmInterface);\n} catch (e) {\n    logger.error('RNNoise init failed, disabling effect', e);\n    // fall back to no noise suppression\n    processor = null;\n}","handlingStrategy":"try-catch","validationCode":"const wasmReady = (iface: { _malloc?: unknown, _rnnoise_create?: unknown }) =>\n    typeof iface._malloc === 'function' && typeof iface._rnnoise_create === 'function';\nif (wasmReady(wasmInterface)) { new RnnoiseProcessor(wasmInterface); }","typeGuard":"null","tryCatchPattern":"try {\n    this._rnnoiseProcessor = new RnnoiseProcessor(wasmInterface);\n} catch (e) {\n    logger.error('RNNoise unavailable, continuing without noise suppression', e);\n    this._rnnoiseProcessor = null; // graceful degradation, no effect applied\n}","preventionTips":["Instantiate the processor only after the wasm module fully loads.","Always call destroy() on failed or replaced processors to free _malloc'd buffers.","Keep rnnoise.wasm and its JS glue from the same package version; verify asset sizes in CI.","Avoid constructing multiple processors concurrently for the same track."],"tags":["wasm","rnnoise","noise-suppression","audio-effects","memory"],"backgroundTag":"wasm-allocation-failed","analyzedSha":"98de6219cc7ddbe07ace9fde045aff90a242ba01","analyzedAt":"2026-08-28T15:15:59.482Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}