Closed Bug 1138343 Opened 9 years ago Closed 9 years ago

[UserDictionary] Instantiate and store an ArrayBuffer instead of a TypedArray during dictionary binary blob generation in KeyboardSettingsApp

Categories

(Firefox OS Graveyard :: Gaia::Keyboard, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
2.2 S7 (6mar)

People

(Reporter: mnjul, Assigned: mnjul)

References

Details

(Whiteboard: [p=1])

Attachments

(1 file)

+++ This bug was initially created as a clone of Bug #1102834 +++

Bug 1102834 generated and stored the user dictionary blob as a Uint8Array, in KeyboardSettingsApp. IndexedDB does the serialization/marshalling wonderfully so KeyboardApp latin.js loads the blob as Uint8Array too.

However, in predictions.js we're also creating create new Uint8Array views for that incoming "blob". Now, at [1], the offset parameter will not see any effect: the second constructor for Uint8Array (see [2]) is called, instead of the fourth, because "buffer" in that context, when called with UserDictionary blob, is a Uint8Array.

Thus the "tree" structure is completely wrong and the prediction mechanism breaks.

[1] https://github.com/mozilla-b2g/gaia/blob/master/apps/keyboard/js/imes/latin/predictions.js#L196
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array

Let's amend WordListConverter to return an ArrayBuffer to store into IndexedDB (I did a quick test and that seemed to work).

Note that other callers of predictions.js pass ArrayBuffer (either from XHR for built-in dics or IndexedDB as in bug 1029951) so this is kinda a design oversight during bug 1102834.

Without this bug fixed I can't progress on bug 1102835.
Comment on attachment 8571329 [details] [review]
[gaia] mnjul:bug_1138343_arraybuffer_userdict > mozilla-b2g:master

Tim,

This is the UserDictionary "blocker" I talked about this afternoon. Contrary to what I'd said, I now don't think this actually needs priority to be reviewed (actual code changes are quite minimal, though). I think my bug 1102835 work can continue by overlaying on this patch.

Still, thanks for your time on reviewing this!
Attachment #8571329 - Flags: review?(timdream)
Assignee: nobody → jlu
Status: NEW → ASSIGNED
Whiteboard: [p=1]
Target Milestone: --- → 2.2 S7 (6mar)
Comment on attachment 8571329 [details] [review]
[gaia] mnjul:bug_1138343_arraybuffer_userdict > mozilla-b2g:master

I step on the same mistake once! Sorry for not caught this in the first review!
Attachment #8571329 - Flags: review?(timdream) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: