Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortWork.js crashed when 'dynamicScene': true, with add-->remove-->add opterations. 'dynamicScene': false。 all be OK #346

Open
nmgyaoyuan opened this issue Oct 2, 2024 · 4 comments

Comments

@nmgyaoyuan
Copy link

when i want read splat file and want rotate the splat scene, i found the bug(maybe).

code:
gsViewer = new GaussianSplats3D.Viewer({
'selfDrivenMode': false,
'useBuiltInControls': false,
'dynamicScene': true,
'renderer':renderer,
'camera':camera,
'threeScene':scene,
'sphericalHarmonicsDegree': 2,
'rootElement': splatContainer.value
});
//--------------------------------------------------------------

/* ----copyed from demo code---*/
function runViewer(splatBufferData:ArrayBuffer, format:GaussianSplats3D.SceneFormat,
alphaRemovalThreshold:number, sphericalHarmonicsDegree:number) {
const splatBufferOptions = {
'splatAlphaRemovalThreshold': alphaRemovalThreshold
};
const splatBufferPromise = fileBufferToSplatBuffer({data: splatBufferData}, format, alphaRemovalThreshold, 0,
undefined, undefined, undefined, undefined, sphericalHarmonicsDegree
);

splatBufferPromise.then((splatBuffer:GaussianSplats3D.splatBuffer) => {
    gsViewer.addSplatBuffers([splatBuffer], [splatBufferOptions])
    .then(() => {
        hasSplatInViewer=true;
        console.info('splat is added in viewer');
        emit('added',null);
    });
});

}
//---------------------------------------------------------------------

use runViewer() to add splatFile , is OK. Then use removeSplatScene(0) remove a scene,is OK. and use runViewer() to add splat File again , crashed.

error info:

Uncaught RangeError: offset is out of bounds
at Int32Array.set ()
at self.onmessage (8f7e31cd-0625-419e-9f13-6931e81b4dc9:95:11)
self.onmessage @ 8f7e31cd-0625-419e-9f13-6931e81b4dc9:95
8f7e31cd-0625-419e-9f13-6931e81b4dc9:48 Uncaught RangeError: offset is out of bounds
at Float32Array.set ()
at sort (8f7e31cd-0625-419e-9f13-6931e81b4dc9:48:59)
at self.onmessage (8f7e31cd-0625-419e-9f13-6931e81b4dc9:123:7)

crashed code (2 places) :
(1) ----> new Float32Array(wasmMemory, modelViewProjOffset, 16).set(modelViewProj);
(2) ---->
if (e.data.centers) {
centers = e.data.centers;
sceneIndexes = e.data.sceneIndexes;
if (integerBasedSort) {
new Int32Array(
wasmMemory,
centersOffset + e.data.range.from * Constants2.BytesPerInt * 4,
e.data.range.count * 4
).set(new Int32Array(centers));
} else {

@nmgyaoyuan nmgyaoyuan changed the title sortWork crashed when 'dynamicScene': true, with add-->remove-->add opterations. 'dynamicScene': false。 all be OK sortWork.js crashed when 'dynamicScene': true, with add-->remove-->add opterations. 'dynamicScene': false。 all be OK Oct 2, 2024
@mkkellogg
Copy link
Owner

Sorry for the late reply, are you making sure to wait for removeSplatScene() to complete before attempting to add another scene? It returns a promise like addSplatBuffers()

@nmgyaoyuan
Copy link
Author

nmgyaoyuan commented Oct 14, 2024

yes, waited for the removeSplatScene() returned promise before attempting to add another scene.

`if(gsViewer){

  gsViewer.removeSplatScene(0)
  .then(()=>{
      hasSplatInViewer=false;
      console.info('splat is removed');
      emit('deleted',null);
  })
  .catch((error:Error)=>{
      console.error(`splat remove error:${error}`);
  })

}`

crashed throw from sortWork.js 。

@mkkellogg
Copy link
Owner

If you post your full code, maybe I can run it locally and try to debug it.

@Nyveon
Copy link

Nyveon commented Dec 8, 2024

@nmgyaoyuan does the latest 0.4.6 release fix your issue? I ask because my issue #380 was very similar to yours, and this latest release fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants