mkkellogg / GaussianSplats3D

Three.js-based implementation of 3D Gaussian splatting
MIT License
1.09k stars 134 forks source link

Compatibility issues with rendering on iOS devices. #265

Open whwhwwhwwh opened 4 days ago

whwhwwhwwh commented 4 days ago

Hello, after conducting my tests, there still seems to be an issue with iOS versions below 16.4. I think the following changes can be made to the code in the file /src/worker/SortWorker.js:

// iOS makes choosing the right WebAssembly configuration tricky :(
let iOSSemVer = isIOS() ? getIOSSemever() : null;
if (!enableSIMDInSort && !useSharedMemory) {
    sourceWasm = SorterWasmNoSIMD;
    if (iOSSemVer && iOSSemVer.major < 16) {
        sourceWasm = SorterWasmNoSIMDNonShared;
    }
} else if (!enableSIMDInSort) {
    sourceWasm = SorterWasmNoSIMD;
} else if (!useSharedMemory) {
    if (iOSSemVer && iOSSemVer.major < 16) {
        sourceWasm = SorterWasmNonShared;
    }
}

In the code, change the condition if (iOSSemVer && iOSSemVer.major < 16) { to if (iOSSemVer && iOSSemVer.major <= 16 && iOSSemVer.minor < 4) Moreover, according to the previous logic, the if inside the last else if should not be reachable.

Therefore, the modified code segment would be:

 // iOS makes choosing the right WebAssembly configuration tricky :(
 const iOSSemVer = isIOS() ? getIOSSemever() : null
 if (!enableSIMDInSort && !useSharedMemory) {
   sourceWasm = SorterWasmNoSIMD
   if (iOSSemVer && iOSSemVer.major <= 16 && iOSSemVer.minor < 4)
     sourceWasm = SorterWasmNoSIMDNonShared
 }
 else if (!enableSIMDInSort) {
   sourceWasm = SorterWasmNoSIMD
 }
mkkellogg commented 3 days ago

I can definitely change the version test to:

if (iOSSemVer && iOSSemVer.major <= 16 && iOSSemVer.minor < 4)

However the last existing else block is reachable when enableSIMDInSort is true, but useSharedMemory is false, so I'd like to keep it. It should really be:

} else if (!useSharedMemory) {
    sourceWasm = SorterWasmNonShared;
}
whwhwwhwwh commented 3 days ago

Yes, I agree with your point, haha.