@@ -167,7 +167,10 @@ class GSplatSogsData {
167
167
168
168
packedShN ;
169
169
170
- destroy ( ) {
170
+ // Marked when resource is destroyed, to abort any in-flight async preparation
171
+ destroyed = false ;
172
+
173
+ _destroyGpuResources ( ) {
171
174
this . means_l ?. destroy ( ) ;
172
175
this . means_u ?. destroy ( ) ;
173
176
this . quats ?. destroy ( ) ;
@@ -180,6 +183,11 @@ class GSplatSogsData {
180
183
this . packedShN ?. destroy ( ) ;
181
184
}
182
185
186
+ destroy ( ) {
187
+ this . destroyed = true ;
188
+ this . _destroyGpuResources ( ) ;
189
+ }
190
+
183
191
createIter ( p , r , s , c , sh ) {
184
192
return new GSplatSogsIterator ( this , p , r , s , c , sh ) ;
185
193
}
@@ -438,9 +446,13 @@ class GSplatSogsData {
438
446
const { device, height, width } = this . means_l ;
439
447
440
448
// copy back means_l and means_u data so cpu reorder has access to it
449
+ if ( this . destroyed || device . _destroyed ) return ; // skip the rest if the resource was destroyed
441
450
this . means_l . _levels [ 0 ] = await readImageDataAsync ( this . means_l ) ;
451
+
452
+ if ( this . destroyed || device . _destroyed ) return ; // skip the rest if the resource was destroyed
442
453
this . means_u . _levels [ 0 ] = await readImageDataAsync ( this . means_u ) ;
443
454
455
+ if ( this . destroyed || device . _destroyed ) return ; // skip the rest if the resource was destroyed
444
456
this . packedTexture = new Texture ( device , {
445
457
name : 'sogsPackedTexture' ,
446
458
width,
@@ -472,8 +484,10 @@ class GSplatSogsData {
472
484
}
473
485
} ) ;
474
486
487
+ if ( this . destroyed || device . _destroyed ) return ; // skip the rest if the resource was destroyed
475
488
this . packGpuMemory ( ) ;
476
489
if ( this . packedShN ) {
490
+ if ( this . destroyed || device . _destroyed ) return ; // skip the rest if the resource was destroyed
477
491
this . packShMemory ( ) ;
478
492
}
479
493
}
0 commit comments