fix(cluster): drop bogus AkAlloca and reset per-frame state#5
Conversation
CreateOutputObject passed (AkAudioObject*)AkAlloca(sizeof(AkAudioObject*)) as its output slot: a miscopy of the SDK Particle Generator example. The alloca'd buffer is never used (the real slot is &newObject) and the value is overwritten by CreateOutputObjects before being read -- dead code, not active stack corruption. Use a nullptr slot, matching the SDK example and the ownership model GetOutputObjects already uses in ObjectClusterFX. performClustering never cleared sse_values (push_back'd every iteration of every audio frame): unbounded growth plus a stale-indexed convergence test. Clear it and assign labels so each run starts from clean state.
9c32e3b to
0bcdf98
Compare
Thanks again for the review and the doc links - I dug into the "Creating Sound Engine Object Processor Plug-ins" page you sent, and I think it actually settles this line in the patch's favour. Let me lay it out so you can sanity-check me. The SDK doc states for
So the caller allocates the array of pointers; the objects themselves are created by AkAudioObject ** arNewObjects = (AkAudioObject**)AkAlloca(numObjsOut * sizeof(AkAudioObject*));
AkAudioObjects outputObjects;
outputObjects.uNumObjects = numObjsOut;
outputObjects.ppObjectBuffers = nullptr;
outputObjects.ppObjects = arNewObjects;
if (m_pContext->CreateOutputObjects(in_objects.ppObjectBuffers[i]->GetChannelConfig(), outputObjects) == AK_Success)
{
AkAudioObject * pObject = arNewObjects[iObj]; // engine filled the slotThe official In Utilities.cpp#L60-L66, The original line: AkAudioObject* newObject = (AkAudioObject*)AkAlloca(sizeof(AkAudioObject*));looks like a miscopy of that example: the For what it's worth, I didn't rely on the SDK docs alone - I also cross-checked against an existing convention in this codebase. I've also amended the commit message to reflect reality more accurately: the original called the old On testing - honest disclosure unchanged: I don't have a Wwise authoring + game build env available right now, so I validated this against the SDK contract and the documented examples rather than at runtime, and was hoping to lean on a CI build if one is wired into the pipeline. I'm a bit rusty on modern C++ too, so please push back if I've misread anything. If there's no CI, I'm glad to write up the exact frames/scenarios that exercise |
|
Hi, While i don't want to presume anything, i think its reasonable to expect contributors to build and test their code before making a submission. Regarding Wwise you can get a free personal license and use their C++ SDK along with their CLI tools for building any wwise plugin. If you don't want to use one of these engines you can either use Wwise's:
Please bear with us as we are still currently working on open sourcing fully the engine and several parts are not out yet and some processes not finalized. On a different note, I realize that what i have listed here today should be added to the If you need any help with building/testing the plugin reply to this thread and we will figure it out together. |
|
Thanks a lot for the detailed pointers and for being upfront about the in-flight contribution guidelines - no worries at all on that front. That all sounds completely reasonable to me. I'd much rather build and validate this at runtime myself than lean on your pipeline, so I'm happy to wait. It actually gives me the time to set up a proper local build/test environment: I'll grab the free Wwise personal license + C++ SDK and CLI tools, work through the "Creating Audio Plug-ins" guide, and then exercise the change with the Integration Demo Sample (or one of the sample games) so I can confirm both the |
Summary
Fixes a stack-corruption risk and an unbounded per-frame memory growth in
the real-time clustering path.
Problem
CreateOutputObjectdidAkAlloca(sizeof(AkAudioObject*))and treatedit as an
AkAudioObject.CreateOutputObjectsonly needs a singlepointer slot it fills itself, so the alloca was wrong and a
stack-corruption hazard.
performClusteringnever clearedsse_values, which ispush_back'devery iteration of every audio frame — unbounded memory growth plus a
convergence test indexed by
iteragainst stale data.Fix
Use a null pointer slot (matching the existing pattern in
ObjectClusterFX.cpp). Clearsse_valuesandassignlabels at the startof
performClusteringso each run starts clean.Type
Stability (stack corruption) + real-time correctness/memory (Critical).
Testing
Manual review; output-object creation now follows the Wwise SDK contract;
clustering state is per-call.