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

Compatibility issues with rendering on iOS devices. #265

Open
whwhwwhwwh opened this issue Jun 25, 2024 · 5 comments
Open

Compatibility issues with rendering on iOS devices. #265

whwhwwhwwh opened this issue Jun 25, 2024 · 5 comments

Comments

@whwhwwhwwh
Copy link

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
Copy link
Owner

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
Copy link
Author

Yes, I agree with your point, haha.

@whwhwwhwwh
Copy link
Author

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;
}

After testing, I've discovered that modifying the code to:

} else if (!useSharedMemory) {
    sourceWasm = SorterWasmNonShared;
}

results in the following error when SharedMemory is disabled in desktop browsers:

error: 'WebAssembly.instantiate(): Import #0 "env" "memory…hared state of memory, declared = 0, imported = 1'

@mkkellogg
Copy link
Owner

Actually I think that block should be:

} else if (!useSharedMemory) {
   if (iOSSemVer && iOSSemVer.major <= 16 && iOSSemVer.minor < 4)
      sourceWasm = SorterWasmNonShared;
   }
}

It seems like we should only use the non-shared option for web assembly modules when it's iOS < 16.4. I honestly don't know how the non-shared web assembly modules work at all because when I instantiate the web assembly module here:

memory: new WebAssembly.Memory({

I always specify shared memory. This is only shared between the web assembly module and the web worker; it's different that the shared memory between the web worker and the viewer.

@mkkellogg
Copy link
Owner

Just circling back to this one -- I've made some slight changes to the WASM module selection for iOS in the memory-optimizations branch. Would you be able to try that out to see if it works for you?

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

2 participants