elemental2 icon indicating copy to clipboard operation
elemental2 copied to clipboard

IndexedDB Broken in iOS 13 Mobile Safari

Open washowasho opened this issue 4 years ago • 15 comments

Since upgrading to iOS 13.1.2, Mobile Safari seems to dislike my implementation of IndexedDB through Elemental2. I'm specifically getting the error of "AbortError: The operation was aborted" when attempting to either open the IndexedDB or executing onupgradeneeded. Everything seems to work fine on iOS 12. So was there an update to Mobile Safari's IndexedDB implementation in the latest rounds of updates? I can't seem to find any documentation on it. I know this may be a bit out of scope for Elemental2... but I want to find out if this is specific to Elemental2 or the underlying JavaScript.

I am finding that it's failing on this line:

IDBDatabase db = (IDBDatabase) openDbRequest.result;

Thanks.

washowasho avatar Oct 10 '19 01:10 washowasho

I confirmed this is an Elemental2 problem. I'm using 1.0 RC1 since I can't use 1.0 due to GWT 2.9 not really existing yet.

washowasho avatar Oct 10 '19 17:10 washowasho

You can try a non-official release of elemental2 to see if that fixes your problem.

See https://groups.google.com/forum/#!msg/google-web-toolkit/IgsSl2WVhzo/OXjZRpV_AwAJ for the last one that is compatible with gwt 2.8.2

realityforge avatar Oct 10 '19 21:10 realityforge

@realityforge - Thanks for the recommendation. This also doesn't work. I'm at a loss. Anyone else on this board having the same problem with Mobile Safari?

washowasho avatar Oct 11 '19 02:10 washowasho

I ended up temporarily going back to using JSNI to interact with the raw JavaScript instead of using IndexedDB through Elemental2/JsInterop.

It would be very helpful to know if others can reproduce this and maybe why this is happening. Anyone else willing to volunteer to see if they can replicate?

washowasho avatar Oct 12 '19 11:10 washowasho

What code do you use in your jnsi snippet?

jDramaix avatar Nov 12 '19 01:11 jDramaix

This works: $wnd.db = DBOpenRequest.result;

But this doesn't: IDBDatabase db = (IDBDatabase) openDbRequest.result;

washowasho avatar Nov 12 '19 01:11 washowasho

I need a bit more context. DBOpenRequest and DBOpenRequest do not seem to be the same object.

Could you give us a small code snippet that we can use for reproducing the error? And a code snippet where it works?

jDramaix avatar Nov 12 '19 01:11 jDramaix

Julien - Sorry. Here's some more code that makes sense:

This works (JSNI):

$wnd.indexedDB = $wnd.indexedDB || $wnd.mozIndexedDB || $wnd.webkitIndexedDB || $wnd.msIndexedDB;
		
var DBOpenRequest = $wnd.indexedDB.open("databasenamehere", 1);
		
DBOpenRequest.onerror = function(event) {
     console.error("Error loading database.");
};
		 
DBOpenRequest.onsuccess = function(event) {  
     $wnd.db = DBOpenRequest.result;
;
	
DBOpenRequest.onupgradeneeded = function(event) 
{
      var db = this.result;   //this works
}

This does not work (Elemental2):

elemental2.dom.Window w = DomGlobal.window;

IndexedDbWindow idbw = IndexedDbWindow.of(w);

IDBFactory idb = IndexedDbGlobal.indexedDB;

if (idb != null)
{
	//Window.alert("using IndexedDbGlobal.indexedDB");
}
else if (idbw.webkitIndexedDB != null)
{
	Window.alert("using idbw.webkitIndexedDB");
	idb = idbw.webkitIndexedDB;
}
else if (idbw.moz_indexedDB != null)
{
	Window.alert("using idbw.moz_indexedDB");
	idb = idbw.moz_indexedDB;
}
else if (idbw.mozIndexedDB != null)
{
	Window.alert("using idbw.mozIndexedDB");
	idb = idbw.mozIndexedDB;
}
else if (idbw.msIndexedDB != null)
{
	Window.alert("using idbw.msIndexedDB");
	idb = idbw.msIndexedDB;
}

if (idb == null)
{
	Window.alert("ERROR: IndexedDB Not Found!");
	return;
}

final IDBOpenDBRequest openDbRequest = idb.open("databasenamehere", 1);

openDbRequest.onupgradeneeded = new IDBOpenDBRequest.OnupgradeneededFn() 
{	
	@Override
	public Object onInvoke(IDBVersionChangeEvent e) 
	{
		IDBDatabase db = (IDBDatabase) openDbRequest.result;  // fails here on iOS 13 Mobile Safari
        }
}

washowasho avatar Nov 12 '19 02:11 washowasho

Were you able to reproduce?

washowasho avatar Nov 16 '19 13:11 washowasho

Were you able to reproduce?

washowasho avatar Nov 25 '19 04:11 washowasho

Not yet. I just wanted to have a reproducible example. That will help when I take a look at this bug

jDramaix avatar Nov 25 '19 18:11 jDramaix

Were you able to reproduce?

washowasho avatar Feb 28 '20 01:02 washowasho

So I won't be able to reproduce the problem as I don;t have access to an environment with iOS 13 mobile safari. But we can try to debug together.

"AbortError: The operation was aborted" is a generic error meaning that the operation has been aborted due to another error. Don't you have another stacktrace in your log? My guess is that GWT throws an exception when the line IDBDatabase db = (IDBDatabase) openDbRequest.result; is executed.

jDramaix avatar Feb 28 '20 18:02 jDramaix

That's correct. The JSNI counterpart for it works fine though.

washowasho avatar Mar 04 '20 05:03 washowasho

So do you have another stacktrace/error in your log?

jDramaix avatar Mar 04 '20 07:03 jDramaix