Closed
Bug 722605
Opened 13 years ago
Closed 12 years ago
AndroidGraphicBuffer whitelist uses linear search
Categories
(Firefox for Android Graveyard :: General, defect, P4)
Tracking
(fennec+)
RESOLVED
FIXED
Firefox 28
Tracking | Status | |
---|---|---|
fennec | + | --- |
People
(Reporter: snorp, Assigned: tstullich)
References
Details
(Whiteboard: [mentor=snorp][lang=c++])
Attachments
(1 file, 4 obsolete files)
3.88 KB,
patch
|
snorp
:
review+
|
Details | Diff | Splinter Review |
We do a linear search on the whitelist for the device's board name. This could impact startup time if it gets to be too long. We should use a binary search or something similar.
Comment 1•13 years ago
|
||
http://mxr.mozilla.org/mozilla-central/source/widget/android/AndroidGraphicBuffer.cpp#484
Does these have to be exact matches?
Reporter | ||
Comment 2•13 years ago
|
||
(In reply to Doug Turner (:dougt) from comment #1)
> http://mxr.mozilla.org/mozilla-central/source/widget/android/
> AndroidGraphicBuffer.cpp#484
>
> Does these have to be exact matches?
Uh...yeah, that would probably be more correct.
Updated•13 years ago
|
Assignee: nobody → snorp
tracking-fennec: --- → +
Priority: -- → P4
Comment 3•12 years ago
|
||
This bug hasn't moved, so I'm turning it into a mentored bug instead.
Assignee: snorp → nobody
Whiteboard: [mentor=snorp]
Updated•12 years ago
|
Whiteboard: [mentor=snorp] → [mentor=snorp][lang=c++]
Assignee | ||
Comment 4•12 years ago
|
||
Is this bug still available to be taken? If so, I would like to work on it if possible.
Comment 5•12 years ago
|
||
Yup. The code that needs to be modified is at http://mxr.mozilla.org/mozilla-central/source/widget/android/AndroidGraphicBuffer.cpp?rev=0f86bf03656b#470. You should start by building Fennec if you haven't done so already; there are instructions at https://wiki.mozilla.org/Mobile/Fennec/Android on how to get set up.
Assignee: nobody → timstullich
Assignee | ||
Comment 6•12 years ago
|
||
Ok, cool. Fennec is being built right now so I have some downtime until it finishes. Maybe I'll get on IRC to get some questions answered in the meantime.
Assignee | ||
Comment 7•12 years ago
|
||
I looked into how I could best implement binary search, but I ran into an issue. I cannot come up with a good way to ensure that I search the left or right subarray after I check whether or not the element exists in the mid point. Is there a way to extract the board name from the device so that I can compare it to the board names on the whitelist?
Updated•12 years ago
|
Flags: needinfo?(snorp)
Reporter | ||
Comment 8•12 years ago
|
||
The best thing here would be to use nsTArray and just use BinaryIndexOf() to find the item. No need to reinvent the wheel :)
Flags: needinfo?(snorp)
Assignee | ||
Comment 9•12 years ago
|
||
OK, that makes sense. I was not aware nsTArray could be used like that. What are some good resources to learn more about the different Classes/Data Structures that are available? I know there are the documentation pages, but if there's something more "noob" friendly that would be great.
Assignee | ||
Comment 10•12 years ago
|
||
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #8)
> The best thing here would be to use nsTArray and just use BinaryIndexOf() to
> find the item. No need to reinvent the wheel :)
I think I have come upon a possible solution, although I am not completely sure if it is any good. I constructed an nsTArray with nsAutoString* elements but that feels like an inefficient solution to me since I am manually adding each board name, which takes up too many lines and makes everything really redundant after which I use BinaryIndexOf(). Is there a more elegant solution, that I am not seeing? I have looked through a bunch of the MDN documentation and just can't come up with anything better at the moment.
Assignee | ||
Comment 11•12 years ago
|
||
Attachment #822617 -
Flags: review?(timstullich)
Assignee | ||
Updated•12 years ago
|
Attachment #822617 -
Flags: review?(timstullich) → review?(snorp)
Reporter | ||
Comment 12•12 years ago
|
||
Comment on attachment 822617 [details] [diff] [review]
Implemented a linear search for the whitelist
Review of attachment 822617 [details] [diff] [review]:
-----------------------------------------------------------------
Fix the few small issues and then I think we can get this in
::: widget/android/AndroidGraphicBuffer.cpp
@@ +449,5 @@
> nullptr
> };
>
> +// Build whitelist to check for board type.
> +static void _initWhiteList(nsTArray<nsString>& list)
InitWhiteList
@@ +497,5 @@
> LOG("disallowing board '%s' due to prefs override", boardUtf8.get());
> return true;
> }
>
> // FIXME: (Bug 722605) use something better than a linear search
You can remove this comment :)
@@ +498,5 @@
> return true;
> }
>
> // FIXME: (Bug 722605) use something better than a linear search
> + nsTArray<nsString> sListAllowed;
You should put this list in a static variable so you only have to initialize it once.
@@ +502,5 @@
> + nsTArray<nsString> sListAllowed;
> + int i = -1;
> +
> + _initWhiteList(sListAllowed);
> +
whitespace
Attachment #822617 -
Flags: review?(snorp) → review-
Assignee | ||
Comment 13•12 years ago
|
||
Attachment #822617 -
Attachment is obsolete: true
Attachment #822804 -
Flags: review?(snorp)
Reporter | ||
Comment 14•12 years ago
|
||
Comment on attachment 822804 [details] [diff] [review]
Small fixes made based on first review.
Review of attachment 822804 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/android/AndroidGraphicBuffer.cpp
@@ +486,2 @@
> int i = -1;
> + InitWhiteList(sListAllowed);
You only need to do this once now
Attachment #822804 -
Flags: review?(snorp) → review-
Assignee | ||
Comment 15•12 years ago
|
||
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #14)
> Comment on attachment 822804 [details] [diff] [review]
> Small fixes made based on first review.
>
> Review of attachment 822804 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: widget/android/AndroidGraphicBuffer.cpp
> @@ +486,2 @@
> > int i = -1;
> > + InitWhiteList(sListAllowed);
>
> You only need to do this once now
Oh, my mistake. Do you mean something like this static nsTArray<nsString> sListAllowed = InitWhiteList(sListAllowed); ?
Assignee | ||
Comment 16•12 years ago
|
||
Hopefully this changes the static reference issue. If not, I am not certain how else this issue can be resolved and I would need some further feedback.
Attachment #822804 -
Attachment is obsolete: true
Attachment #822811 -
Flags: review?(snorp)
Assignee | ||
Comment 17•12 years ago
|
||
Attachment #822811 -
Attachment is obsolete: true
Attachment #822811 -
Flags: review?(snorp)
Attachment #823496 -
Flags: review?(snorp)
Reporter | ||
Comment 18•12 years ago
|
||
Comment on attachment 823496 [details] [diff] [review]
The final patch for this bug. Includes all fixes.
Review of attachment 823496 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good :)
Attachment #823496 -
Flags: review?(snorp) → review+
Reporter | ||
Comment 19•12 years ago
|
||
Assignee | ||
Comment 20•12 years ago
|
||
Attachment #823496 -
Attachment is obsolete: true
Attachment #823524 -
Flags: review?(snorp)
Reporter | ||
Updated•12 years ago
|
Attachment #823524 -
Flags: review?(snorp) → review+
Reporter | ||
Comment 21•12 years ago
|
||
Comment 22•12 years ago
|
||
> "omap4sdp"
> "SGH-I897"
> "sgh-i997"
Oughtn't this list be case sensitively sorted?
> int i = -1;
> if ((i = sListAllowed.BinaryIndexOf(board)) >= 0) {
This seems to be a silent cast from unsigned to signed, better to keep it unsigned and compare against NoIndex I guess.
Comment 23•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 28
Comment 24•12 years ago
|
||
> Oughtn't this list be case sensitively sorted?
Ping. Can someone verify that the whitelist still works after this change?
Updated•12 years ago
|
Flags: needinfo?(snorp)
Reporter | ||
Comment 25•12 years ago
|
||
(In reply to Simon Lindholm from comment #24)
> > Oughtn't this list be case sensitively sorted?
> Ping. Can someone verify that the whitelist still works after this change?
I'll look
Flags: needinfo?(snorp)
Comment 26•11 years ago
|
||
Any update?
Reporter | ||
Comment 27•11 years ago
|
||
(In reply to Simon Lindholm from comment #26)
> Any update?
We don't use this code anywhere, so it hasn't been a priority.
Updated•5 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•