google/elemental2

IndexedDB Broken in iOS 13 Mobile Safari

washowasho opened this issue · 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.

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.

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 - 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?

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?

What code do you use in your jnsi snippet?

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

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

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?

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
        }
}

Were you able to reproduce?

Were you able to reproduce?

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

Were you able to reproduce?

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.

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

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