Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Issue 2512123002: Shape Detection: QR detection in Chrome Android using Play Services (Closed)

Created:
4 years, 1 month ago by mcasas
Modified:
4 years ago
CC:
chromium-reviews, creis+watch_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, nasko+codewatch_chromium.org, jam, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, dglazkov+blink, darin-cc_chromium.org, agrieve+watch_chromium.org, blink-reviews, darin (slow to review), blink-reviews-api_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Shape Detection: QR detection in Chrome Android using Play Services This CL adds a java interface implementation for Barcode detection. Since it uses the Google Play Services "vision" category [1], this is landed under chrome/, and hangs under the ChromeInterfaceRegistrar.java. Intent to implement: https://groups.google.com/a/chromium.org/forum/m/#!topic/blink-dev/JkdoxpINjxQ Test: I'm planning to add a browser_test soon; however since bots might now have the necessary Play services, I'd rather land it in a followup CL. BUG=665150 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation TEST=http://codepen.io/miguelao/pen/bBWOzM, see e.g. https://drive.google.com/file/d/0B82Jhdx0kSTVb3g5b2xOTWozd3M/view?pli=1 [1] https://developers.google.com/android/reference/com/google/android/gms/vision/barcode/package-summary Committed: https://crrev.com/a9431a4ed6f1bccd426271370ddd6b9530ff39c9 Cr-Commit-Position: refs/heads/master@{#435781}

Patch Set 1 : #

Total comments: 4

Patch Set 2 : dgn@ and dcheng@s comments, rebase and checking |web_contents| before use. #

Total comments: 5

Patch Set 3 : dcheng@ request to check for |numPixels| overflow #

Total comments: 4

Patch Set 4 : moar comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+182 lines, -1 line) Patch
M chrome/android/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/mojo/ChromeInterfaceRegistrar.java View 2 chunks +4 lines, -0 lines 0 comments Download
A chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionFactory.java View 1 chunk +39 lines, -0 lines 0 comments Download
A chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java View 1 2 3 1 chunk +118 lines, -0 lines 0 comments Download
M chrome/android/java_sources.gni View 1 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/browser/DEPS View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/chrome_content_browser_client.cc View 1 3 chunks +16 lines, -1 line 0 comments Download
M chrome/browser/chrome_content_browser_manifest_overlay.json View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 58 (29 generated)
mcasas
dgn@ PTAL
4 years ago (2016-11-24 00:08:22 UTC) #9
dcheng
https://codereview.chromium.org/2512123002/diff/80001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java File chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java (right): https://codereview.chromium.org/2512123002/diff/80001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java#newcode67 chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java:67: || numPixels > MOJO_SHAREDBUFFER_MAX_BYTES / 4) { Drive-by: this ...
4 years ago (2016-11-24 04:31:39 UTC) #11
dgn
not lgtm, because using the new APIs has to wait until they are available downstream ...
4 years ago (2016-11-24 10:32:32 UTC) #12
dgn
CL up for review at https://chrome-internal-review.googlesource.com/#/c/307576/
4 years ago (2016-11-24 16:40:30 UTC) #13
mcasas
Notwithstanding https://chrome-internal-review.googlesource.com/#/c/307576/, and just to have this CL ready when the moment arrives, PTAL. https://codereview.chromium.org/2512123002/diff/80001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java ...
4 years ago (2016-11-28 22:03:38 UTC) #16
mcasas
dgn@, dcheng@ ping
4 years ago (2016-11-29 18:43:29 UTC) #21
mcasas
dgn@, dcheng@ ping
4 years ago (2016-11-29 18:43:30 UTC) #22
dgn
CL landed, lgtm :)
4 years ago (2016-11-29 21:04:16 UTC) #23
mcasas
dtrainor@ plz RS chrome/android changes /PTAL thakis@: RS plz chrome/browser/ DEPS and chrome_content_browser_client.cc thx
4 years ago (2016-11-29 21:52:25 UTC) #25
Bernhard Bauer
I do have a security-ish question, but given that IPC OWNERS will need to sign-off ...
4 years ago (2016-11-30 17:09:45 UTC) #27
David Trainor- moved to gerrit
lgtm % bauerb@'s question.
4 years ago (2016-11-30 18:07:05 UTC) #28
mcasas
dcheng@ PTAL https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java File chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java (right): https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java#newcode62 chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java:62: final long numPixels = (long) width * ...
4 years ago (2016-11-30 19:57:09 UTC) #30
Nico
I can't find the "intent to implement" blink-dev thread for this. can you point me ...
4 years ago (2016-11-30 20:00:49 UTC) #31
mcasas
On 2016/11/30 20:00:49, Nico wrote: > I can't find the "intent to implement" blink-dev thread ...
4 years ago (2016-11-30 20:11:25 UTC) #32
Nico
can you link to that on the bug? On Wed, Nov 30, 2016 at 3:11 ...
4 years ago (2016-11-30 20:17:57 UTC) #33
Nico
can you link to that on the bug? On Wed, Nov 30, 2016 at 3:11 ...
4 years ago (2016-11-30 20:17:59 UTC) #34
mcasas
On 2016/11/30 20:17:59, Nico wrote: > can you link to that on the bug? > ...
4 years ago (2016-11-30 20:28:38 UTC) #36
Bernhard Bauer
https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java File chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java (right): https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java#newcode62 chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java:62: final long numPixels = (long) width * height; On ...
4 years ago (2016-11-30 23:01:35 UTC) #37
Nico
chrome/ rs-lgtm
4 years ago (2016-11-30 23:35:24 UTC) #38
dcheng
https://codereview.chromium.org/2512123002/diff/200001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java File chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java (right): https://codereview.chromium.org/2512123002/diff/200001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java#newcode63 chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java:63: if (!frameData.isValid() || width <= 0 || height <= ...
4 years ago (2016-12-01 06:15:07 UTC) #40
mcasas
https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java File chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java (right): https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java#newcode62 chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java:62: final long numPixels = (long) width * height; On ...
4 years ago (2016-12-01 16:05:51 UTC) #41
dcheng
mojo lgtm https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java File chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java (right): https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java#newcode62 chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java:62: final long numPixels = (long) width * ...
4 years ago (2016-12-01 22:10:46 UTC) #46
Bernhard Bauer
On 2016/12/01 22:10:46, dcheng wrote: > mojo lgtm > > https://codereview.chromium.org/2512123002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java > File > chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java ...
4 years ago (2016-12-01 23:51:49 UTC) #47
haraken
On 2016/12/01 23:51:49, Bernhard Bauer wrote: > On 2016/12/01 22:10:46, dcheng wrote: > > mojo ...
4 years ago (2016-12-01 23:55:06 UTC) #48
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2512123002/220001
4 years ago (2016-12-01 23:57:40 UTC) #51
commit-bot: I haz the power
Committed patchset #4 (id:220001)
4 years ago (2016-12-02 00:04:41 UTC) #54
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/a9431a4ed6f1bccd426271370ddd6b9530ff39c9 Cr-Commit-Position: refs/heads/master@{#435781}
4 years ago (2016-12-02 00:07:03 UTC) #56
Nico
On Thu, Dec 1, 2016 at 6:55 PM, <haraken@chromium.org> wrote: > On 2016/12/01 23:51:49, Bernhard ...
4 years ago (2016-12-02 01:21:53 UTC) #57
Nico
4 years ago (2016-12-02 01:21:54 UTC) #58
Message was sent while issue was closed.
On Thu, Dec 1, 2016 at 6:55 PM, <haraken@chromium.org> wrote:

> On 2016/12/01 23:51:49, Bernhard Bauer wrote:
> > On 2016/12/01 22:10:46, dcheng wrote:
> > > mojo lgtm
> > >
> > >
> >
> https://codereview.chromium.org/2512123002/diff/140001/
> chrome/android/java/src/org/chromium/chrome/browser/shapedetection/
> BarcodeDetectionImpl.java
> > > File
> > >
> >
> chrome/android/java/src/org/chromium/chrome/browser/shapedetection/
> BarcodeDetectionImpl.java
> > > (right):
> > >
> > >
> >
> https://codereview.chromium.org/2512123002/diff/140001/
> chrome/android/java/src/org/chromium/chrome/browser/shapedetection/
> BarcodeDetectionImpl.java#newcode62
> > >
> >
> chrome/android/java/src/org/chromium/chrome/browser/shapedetection/
> BarcodeDetectionImpl.java:62:
> > > final long numPixels = (long) width * height;
> > > On 2016/12/01 16:05:51, mcasas wrote:
> > > > On 2016/11/30 23:01:34, Bernhard Bauer wrote:
> > > > > On 2016/11/30 19:57:09, mcasas wrote:
> > > > > > On 2016/11/30 17:09:45, Bernhard Bauer wrote:
> > > > > > > Are we doing any additional sanity checks of the values here?
> I'm
> > going
> > > to
> > > > > > > assume that the Mojo internals would be able to check the
> really
> > > dangerous
> > > > > > stuff
> > > > > > > (like OOB memory accesses in memory mapping), but could a
> compromised
> > > > > renderer
> > > > > > > here get the browser to try to allocate a gigantic bitmap and
> > > subsequently
> > > > > > crash
> > > > > > > due to OOM?
> > > > > >
> > > > > > The input |frameData| is a shared memory, so
> > > > > > it needs to be mapped in l.68 and that's where
> > > > > > the checks take place: map() will fail if we try
> > > > > > to map too large a memory. Also, mojo SharedBuffers
> > > > > > have a limit in its intrinsic size which used
> > > > > > to be ~16MB, and now is |max_shared_memory_num_bytes|
> > > > > > in mojo::edk::Configuration [1]. I added a comment
> > > > > > to make all this evident.
> > > > > >
> > > > > > [1]
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cs.chromium.org/chromium/src/mojo/edk/
> embedder/configuration.h?dr=C&q=mojo/edk/embedder/
> configuration.h&sq=package:chromium&l=63
> > > > >
> > > > > I'm actually less concerned about the mapping failing, because that
> memory
> > > > > already exists somewhere. What I'm more concerned about is
> allocating
> the
> > > > > Bitmap. I think if the passed width * height * 4 would be bigger
> than
> the
> > > > actual
> > > > > size of the buffer, we would abort before that happens, but that
> still
> > means
> > > > an
> > > > > allocation of up to 16 MB. It doesn't sound like much, but I'm
> pretty
> > > certain
> > > > 16
> > > > > MB can push a process on Android into OOM territory – as an
> example, we
> > take
> > > > > screenshots of the New Tab Page for using in the tab switcher, and
> we
> used
> > > to
> > > > > get OOM crashes for that allocation (which I think is less than
> 16MB).
> > > > >
> > > >
> > > > This is interesting and sad information.
> > > >
> > > > For the sister Face Detection, we are writing a //services/
> > > > so that we can move the implementation out of process
> > > > to avoid any potential crashes from spreading. I believe,
> > > > however, that //services cannot implement //chrome code, so
> > > > we might need some further tweaking there. (Just FTR,
> > > > this feature is behind an experimental flag).
> > > >
> > > > In the meantime, would verifying that we are not in a
> > > > TRIM_MEMORY_RUNNING_*/TRIM_MEMORY_MODERATE [1] situation
> > > > help?
> > > >
> > > > [1]
> > > >
> > >
> >
> https://developer.android.com/reference/android/content/
> ComponentCallbacks2.html
> > > >
> > > > > Would it be totally unreasonable to have the renderer send the
> data in
> one
> > > of
> > > > > the accepted formats for
> > > > >
> > > >
> > >
> >
> https://developers.google.com/android/reference/com/google/
> android/gms/vision/Frame.Builder.html#setImageData(java.nio.ByteBuffer,
> > > > > int, int, int) and then use that? Reading the docs for Frame, it
> looks
> > like
> > > > > going through a Bitmap would actually require two allocations :-/
> > > >
> > > > Sadly, correct: the incoming |frameData| has to be wrapped
> > > > into |bitmap|, which is then converted to a |frame|, which
> > > > implies a conversion to either NV16, NV21, or YV12 in l.83
> > > > RHS. The issue is that data is coming directly from Blink
> > > > where Skia primitives like to work in 32bpp formats and we
> > > > have to avoid data conversions there... I see this as a
> > > > matter of optimizations?
> > > >
> > >
> > > As a counter point... a number of security team members aren't entirely
> > > comfortable with the idea of browser process acting on shared memory
> that
> > could
> > > be mutated from underneath it.
> > >
> > > (It's not to say that it's impossible for this to be safe, but if we
> somehow
> > > changed this code so we never had to copy and could directly use the
> mapped
> in
> > > buffer, we'd want to audit the processing code very very carefully to
> make
> > sure
> > > that changing pixels out from underneath it can't cause it to explode.)
> >
> > Ugh… okay, if you feel copying the data is the lesser of two evils,
> LGTM. It
> > would probably still be a good idea to keep an eye on crash reports due
> to OOM
> > in this area, then we can deal with that if and when it happens.
>
> 16 MB of allocation sounds too big to me on low-RAM devices...
>

(Might be something to bring up on the intent-to-implement thread)


>
> https://codereview.chromium.org/2512123002/
>

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698