dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.49k stars 642 forks source link

Safari save Uint8Array in DB #656

Open fix2015 opened 6 years ago

fix2015 commented 6 years ago

Hi, when i try on Safari 11, save Uint8Array in DB i get nothing. example -> https://jsfiddle.net/3tf5r0cu/425/ so question is Safari support save Uint8Array in indexedDB? screenshot_2

dfahlander commented 6 years ago

jsfiddle runs in an iframe, which doesn't work on Safari (I think the iframe compromizes same-orgin policy or similar). Try putting the code into an HTML page instead.

fix2015 commented 6 years ago

screenshot_3 i tried and have same error

dfahlander commented 6 years ago

I retried and got the same error. After that, all IDB code blocked on open until I restarted Safari. Reloading page didn't help. Changing DB name didn't help. Only a restart of Safari and stop using binary keys. This must be filed in webkit bugzilla. Would you have the time to do that? Hint: Bake the CSS/JS (except dexie.js) into a single HTML file and post it along with the issue. If you can easily host the repro HTML file somewhere, that would make it even easier for Safari developers to reproduce it.

dfahlander commented 6 years ago

Webkit bugzilla: https://bugs.webkit.org/

maximerety commented 6 years ago

Hi there, I'm having the same issue in Safari 11.1 and I have been "playing" a bit around it.

It seems to happen only if you have both:

Non-binary data Binary data
store without autoIncrement
store with autoIncrement

Without autoIncrement, having Uint8Arrays is not an issue (and vice versa).

I've just submitted the issue on Webkit Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=185869

Here's also a gist if you want to confirm the behavior described above: https://gist.github.com/maximerety/2332ed4660652f57ef6e12e3194e28e4

dfahlander commented 6 years ago

@maximerety thanks for nailing down the issue and filling it on webkit Bugzilla!

maximerety commented 6 years ago

@dfahlander You're welcome 😊

As a side-note, I've also reported another issue with Safari and Uint8Array that might also be of interest to the readers of this thread: https://bugs.webkit.org/show_bug.cgi?id=185906

Tl;dr: if retrieving indexedDB records containing "Object" values (e.g. Array, Uint8Array, ArrayBuffer, a.s.o) inside an iframe, instanceof will not work correctly on these values.

An the test case: https://gist.github.com/maximerety/92431f6f4cc9ea8f684de8c124469995