Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexedDB Broken in iOS 13 Mobile Safari #132

Open
washowasho opened this issue Oct 10, 2019 · 15 comments
Open

IndexedDB Broken in iOS 13 Mobile Safari #132

washowasho opened this issue Oct 10, 2019 · 15 comments

Comments

@washowasho
Copy link

washowasho commented Oct 10, 2019

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
Copy link
Author

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.

@realityforge
Copy link
Collaborator

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

@washowasho
Copy link
Author

@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
Copy link
Author

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 washowasho changed the title Mobile Safari Issues? IndexedDB Broken in Mobile Safari Oct 14, 2019
@washowasho washowasho changed the title IndexedDB Broken in Mobile Safari IndexedDB Broken in iOS 13 Mobile Safari Oct 14, 2019
@jDramaix
Copy link
Member

What code do you use in your jnsi snippet?

@washowasho
Copy link
Author

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

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

@jDramaix
Copy link
Member

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?

@washowasho
Copy link
Author

washowasho commented Nov 12, 2019

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
Copy link
Author

Were you able to reproduce?

1 similar comment
@washowasho
Copy link
Author

Were you able to reproduce?

@jDramaix
Copy link
Member

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

@washowasho
Copy link
Author

Were you able to reproduce?

@jDramaix
Copy link
Member

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.

@washowasho
Copy link
Author

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

@jDramaix
Copy link
Member

jDramaix commented Mar 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants