5

I have an existing app which runs on fine in earlier versions of Safari and makes use of an indexedDB polyfill to store data. Most of this activity takes place in a web worker so WebSQL can be accessed from the web worker.

However, I am now trying native indexedDB access using Safari 6.2 and although indexedDB can be referenced in the "main" work thread, when i try to access "self.indexeddb" or "indexeddb" they both come back as undefined.

Has anyone been able to access indexedDB in a web worker in the newest versions of Safari?

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Jonathan Smith
  • 2,390
  • 1
  • 34
  • 60
  • Someone replied to my thread on the Apple Dev forums saying that IndexedDB was not accessible from a web worker, but they did not say anything else. Would be nice if anyone could confirm that they had experienced this in the real world. – Jonathan Smith Sep 04 '14 at 19:28
  • possible duplicate of [Accessing IndexedDB from multiple javascript threads](http://stackoverflow.com/questions/9038379/accessing-indexeddb-from-multiple-javascript-threads) – Paul Sweatte Nov 04 '14 at 17:06
  • No, this is not a duplicate. The referenced question is regarding race conditions. My question was whether it was even possible to access Apple's new implementation of IndexedDB from a web worker - which I have now discovered is NOT possible. – Jonathan Smith Nov 04 '14 at 17:29
  • But doesn't the answer to that question show a solution? – Paul Sweatte Nov 04 '14 at 17:40
  • My question was: "Has anyone been able to access indexedDB in a web worker in the newest versions of Safari?". I also referenced that the version of Safari I was using was version 6.2. This was released on 18th September 2014. The answer to the question you think I am duplicating was posted on 28th January 2012 and makes no reference to Safari. – Jonathan Smith Nov 04 '14 at 17:45
  • How is indexeddb on Safari mobile in 2014 different from indexeddb in 2012? It's a [web standard](https://developer.apple.com/library/mac/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_10.html//apple_ref/doc/uid/TP40014484-DontLinkElementID_2#//apple_ref/doc/uid/TP40014484-DontLinkElementID_2), so a technique to integrate with a web worker in 2012 should be cross-browser compatible and forward-compatible, unless the [implementation is buggy](http://stackoverflow.com/questions/26019147/primary-key-issue-on-ios8-implementation-of-indexeddb). – Paul Sweatte Nov 04 '14 at 17:49
  • It's very buggy. which is why I started that thread you linked to. Although IndexedDb is indeed a web standard, being able to access it via a web worker is not. Chrome and Internet Explorer both provide an interface ("self.indexedDb" I believe) to access IDB from a web worker, but Apple do not. I vote to close this now. It doesn't work and it makes me very sad. – Jonathan Smith Nov 04 '14 at 17:56
  • Ack! Any followup or work around? I am sad too. – GaryBishop Dec 17 '14 at 17:28

1 Answers1

1

Has anyone been able to access indexedDB in a web worker in the newest versions of Safari?

IndexedDB is accessible from Web Worker since Safari Technology Preview Release 5:

Safari Technology Preview is a version of Safari for OS X, distributed by Apple, that includes a cutting-edge, in-development version of the WebKit browser engine. It’s a great way to test upcoming WebKit features and give feedback to the people building them when it’s most useful — early in development.

Released on May 15, 2016. The release notes state:

Enabled IndexedDB in Web Worker scripts

Safari Technology Preview requires a Mac running OS X 10.11.4 or later. Release 5 of Safari Technology Preview covers WebKit revisions 200418–201083.

References

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265