Skip to content

tfjs-tflite: iOS Out of memory error with Cross-Origin Policy #8158

Open
@Jove125

Description

@Jove125

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

0

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>

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions