@@ -113,8 +113,8 @@ function createWasmAudioWorkletProcessor(audioParams) {
113113 // _emscripten_stack_alloc(), as were the output views, and so to ensure
114114 // the views fall on the correct addresses (and we finish at the stacktop)
115115 // bytes are added and the start advanced.
116- entry = ( stackMemoryNeeded + 15 ) & ~ 15 ;
117- var dataPtr = stackAlloc ( entry ) + ( entry - stackMemoryNeeded ) ;
116+ var alignedNeededStack = ( stackMemoryNeeded + 15 ) & ~ 15 ;
117+ var dataPtr = stackAlloc ( alignedNeededStack ) ;
118118
119119 // Copy input audio descriptor structs and data to Wasm (recall, structs
120120 // first, audio data after). 'inputsPtr' is the start of the C callback's
@@ -150,6 +150,12 @@ function createWasmAudioWorkletProcessor(audioParams) {
150150 dataPtr + = subentry . length * { { { getNativeTypeSize ( 'float' ) } } } ;
151151 }
152152
153+ // TODO: why does Chrome wasm64 (Chrome has weird rules for params) need
154+ // the manual alignment here? An off-by-one somewhere? outputsPtr is
155+ // getting clobbered otherwise, is the struct correctly aligned? Do more
156+ // stack allocs instead? Probably needs alignments between struct writes?
157+ dataPtr + = alignedNeededStack - stackMemoryNeeded ;
158+
153159 // Copy output audio descriptor structs to Wasm. 'outputsPtr' is the start
154160 // of the C callback's output AudioSampleFrame.
155161 // Note: dataPtr after the struct offsets should now be 16-byte aligned.
0 commit comments