tfjs-tflite: iOS Out of memory error with Cross-Origin Policy
Hi,
According to this recomendations, it is necessary setting up cross-origin isolation: https://github.com/tensorflow/tfjs/tree/master/tfjs-backend-wasm#setting-up-cross-origin-isolation
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
After these settings, neural networks on a desktop PC and on android devices begin to work much faster. But the following error occurs on the iPhone (tested on iPhone 6S and 13 Max Pro). How can it be avoided?
Unhandled Promise Rejection: RangeError: Out of memory
promiseEmptyOnRejected — tflite_web_api_cc_threaded.js:287
promiseReactionJob
if to remove the server cross-origin settings, then everything works on the iPhone, but slowly.
html code to reproduce error:
<script src="./node_modules/@tensorflow/tfjs-core/dist/tf-core.min.js"></script>
<script src="./node_modules/@tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.min.js"></script>
<script src="./node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.min.js"></script>
<script>
var promise = tflite.loadTFLiteModel(modelPath, {numThreads: 4});
</script>
This issue still persists one year after with TensorFlow.js version 4.22.0 on iOS Safari browser.
Any update on this issue?
I've reproduced this issue with the following steps:
- Cloned a repo,
- Started a https server with Cross-Origin Policy on location "e2e/benchmarks",
- Opened a web page on an iOS Safari browser,
- Selected MobileNetV3 model with tflite backend,
- Pressed "Run benchmark",
- Message "Error: Out of memory..." occurred.
This issue does not happen on Windows with Firefox and Edge (chromium) browsers. I've also tested this on a Samsung Galaxy S24, S22 and Google Pixel 6 on mobile Chrome browser and there was not a single issue.
If it is not a problem with TensorFlow.js but Safari is there a known workaround for an iOS Safari?