Bug 138504

Summary: [IndexedDB] array index keys are concatenated across cursor lifetime
Product: WebKit Reporter: Chris Anderson <jchris>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: alecflett, beidson, commit-queue, jchris, jsbell, nolan, simon.fraser, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: iOS 8.1   
Attachments:
Description Flags
Patch
none
Patch beidson: review-

Chris Anderson
Reported 2014-11-07 07:47:15 PST
The following test passes in Firefox and Chrome but not Safari (Safari v8 Engine: WebKit v600.1.25 OS: Mac OS X v10.10 and Mobile Safari v8 Engine: WebKit v600.1.4 OS: iOS v10.10) http://requirebin.com/?gist=fcc75007aa20e504bcd4 multiEntry works fine when the members of the multiEntry array are numbers, but when they are arrays, everything goes sideways. It looks like the arrays are being flattened and concated. My test case only uses one layer of nesting but I discovered it in an application that uses multiple layers of nesting (I'm converting deep objects to nested arrays so I can have a defined collation over objects when used as keys.)
Attachments
Patch (5.62 KB, patch)
2014-12-12 14:12 PST, Mark Dixon
no flags
Patch (5.62 KB, patch)
2014-12-12 17:55 PST, Mark Dixon
beidson: review-
Chris Anderson
Comment 1 2014-11-07 09:26:39 PST
Oh dear, it's much worse than I thought. Here is the same bug triggered without multiEntry: http://requirebin.com/?gist=4395a44d50f3c6dddcb8
Chris Anderson
Comment 2 2014-11-07 09:35:40 PST
Good news is this might be a presentation concern, as the results come back in the correct order at least.
Chris Anderson
Comment 3 2014-11-07 12:41:02 PST
Maybe this helps diagnose or helps others with workarounds: In my case I know all my keys are 2 element arrays. And the cursor starts with a new correct key on the first row of every transaction. So if your keys are big, paginate. And know how many elements are in your array keys, and then you can run key.splice(-n) where n is your array key length. It doesn't flatten it just concats.
Mark Dixon
Comment 4 2014-12-12 14:12:15 PST
Mark Dixon
Comment 5 2014-12-12 17:55:36 PST
Radar WebKit Bug Importer
Comment 6 2015-02-02 09:11:33 PST
Nolan Lawson
Comment 7 2015-06-08 17:29:26 PDT
Those RequireBin tests weren't working for me, so I browserified them. You can open these two links, and if it's green, then they pass, and if it's red, they fail: * http://bl.ocks.org/nolanlawson/b23876ee55085ebb4696 * http://bl.ocks.org/nolanlawson/fa4f74be1810d726db8a I'm seeing successes in Chrome 43 and Firefox 38, but failures in Safari 8.0.7 and Webkit nightly r185316 (all on desktop Yosemite).
Brady Eidson
Comment 8 2015-06-11 11:16:00 PDT
Comment on attachment 243238 [details] Patch It would be useful to check through any of the currently disabled IDB tests to see if this fixes them - Reenabling them would be preferable to changing this test.
Brady Eidson
Comment 9 2015-06-16 13:21:24 PDT
Since Mark isn't around to respond, I just tried the entire suite of IDB tests and this did not change behavior on any of the skipped tests. Therefore the included change seems appropriate to me. r+, will prep for landing.
Brady Eidson
Comment 10 2015-06-16 13:25:49 PDT
Note You need to log in before you can comment on or make changes to this bug.