Add support for selective JNI registration |
|||||
Issue descriptionCurrently, we use base::android::LibraryProcessType to handle JNI registration differently for Monochrome, Webview, and Chrome. For Webview, we don't actually need to register anything explicitly (and we avoid it to save time in startup). We disable manual JNI registration when in Webview processes and then exit before registering using the jni_generator. It would be useful to have more granular control over JNI registration because we want to try enabling multidex in release (see issue 512357). We perform registration in groups (i.e. https://cs.chromium.org/chromium/src/content/app/android/library_loader_hooks.cc?rcl=0&l=48) which becomes a problem if we want to build a main dex file that has a minimal set of classes (and only part of the Java side of a registration "group" is in the main dex file). We should refactor our JNI registration process: - Introduce an enum JniRegistrationType that we use to determine what kind of registration to complete - Remove the notion of LibraryProcessType from native (and Java if possible) since it doesn't have a clear single purpose - Modify Webview and Monochrome entry points to not perform any JNI registration - Add support to register main dex classes only when in non-browser processes if multidex is turned on Design Doc: https://docs.google.com/document/d/1rsVf3UKY_2SbrIj-LfGZuOw3_flb4WPTDE5iPF0FVnc/edit#
,
Dec 20 2016
,
Feb 1 2017
This is fixed now https://codereview.chromium.org/2501193003/
,
Jun 27 2017
Yipeng's automated registration CL ran into some problems that means it doesn't look like the work here is complete: 1) There's still two callsites that use GetLibraryProcessType to determine what to call JNI registration for, instead of the selective registration, in chrome/app/android/chrome_jni_onload.cc and content/app/android/library_loader_hooks.cc 2) Monochrome still uses GetLibraryProcessType to decide which init function to call; this should be replaced with actual separate entry points. 3) GetLibraryProcessType never got removed from anywhere.
,
Jun 28 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/894b62e67820e4a206b062ee39d13498cde3d6cd commit 894b62e67820e4a206b062ee39d13498cde3d6cd Author: Yipeng Wang <yipengw@chromium.org> Date: Wed Jun 28 18:06:33 2017 Enable selective JNI registration for non-browser processes. Currently we only enable the selective JNI registration for the renderer process on the Java side, but use it to decide if a process is a browser process or not on the native side. Change: Enable the selective JNI registration for all non-browser processes on Java side. Bug: 674937 Change-Id: If97814bc5d79cfaa0211e46f785dbab329429d22 Reviewed-on: https://chromium-review.googlesource.com/552778 Reviewed-by: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Richard Coles <torne@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Commit-Queue: Yipeng Wang <yipengw@chromium.org> Cr-Commit-Position: refs/heads/master@{#483059} [modify] https://crrev.com/894b62e67820e4a206b062ee39d13498cde3d6cd/content/public/android/java/src/org/chromium/content/app/ContentChildProcessServiceDelegate.java
,
Jun 28 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4fc72d112fd1b53bd7a0136f0204f182fe3c3310 commit 4fc72d112fd1b53bd7a0136f0204f182fe3c3310 Author: Yuly Novikov <ynovikov@chromium.org> Date: Wed Jun 28 23:50:39 2017 Revert "Enable selective JNI registration for non-browser processes." This reverts commit 894b62e67820e4a206b062ee39d13498cde3d6cd. Reason for revert: crashes in https://build.chromium.org/p/chromium.gpu.fyi/builders/Android%20Release%20%28Nexus%205X%29/builds/8970 Original change's description: > Enable selective JNI registration for non-browser processes. > > Currently we only enable the selective JNI registration for the renderer > process on the Java side, but use it to decide if a process is a browser > process or not on the native side. > > Change: Enable the selective JNI registration for all non-browser processes > on Java side. > > Bug: 674937 > Change-Id: If97814bc5d79cfaa0211e46f785dbab329429d22 > Reviewed-on: https://chromium-review.googlesource.com/552778 > Reviewed-by: Andrew Grieve <agrieve@chromium.org> > Reviewed-by: Richard Coles <torne@chromium.org> > Reviewed-by: Yaron Friedman <yfriedman@chromium.org> > Commit-Queue: Yipeng Wang <yipengw@chromium.org> > Cr-Commit-Position: refs/heads/master@{#483059} TBR=yfriedman@chromium.org,torne@chromium.org,agrieve@chromium.org,yipengw@chromium.org Change-Id: Id2cd35b0a6ac6c3ea9c82a7eec24235d12b2ac37 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 674937 Reviewed-on: https://chromium-review.googlesource.com/553241 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Cr-Commit-Position: refs/heads/master@{#483203} [modify] https://crrev.com/4fc72d112fd1b53bd7a0136f0204f182fe3c3310/content/public/android/java/src/org/chromium/content/app/ContentChildProcessServiceDelegate.java
,
Jun 29 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2665a13c2c0c90a5d9f8ec1215a8af58b0df85c8 commit 2665a13c2c0c90a5d9f8ec1215a8af58b0df85c8 Author: Yipeng Wang <yipengw@chromium.org> Date: Thu Jun 29 20:14:38 2017 Reland: Enable selective JNI registration for non-browser processes. Reverted in: If97814bc5d79cfaa0211e46f785dbab329429d22 Reason for reland: changed SurfaceTextureListener class to main dex. TBR=yfriedman@chromium.org Bug: 674937 Change-Id: I10eea998628514b1b817a909559b3e97d6f0bd47 Reviewed-on: https://chromium-review.googlesource.com/556360 Reviewed-by: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Ted Choc <tedchoc@chromium.org> Commit-Queue: Yipeng Wang <yipengw@chromium.org> Cr-Commit-Position: refs/heads/master@{#483461} [modify] https://crrev.com/2665a13c2c0c90a5d9f8ec1215a8af58b0df85c8/content/public/android/java/src/org/chromium/content/app/ContentChildProcessServiceDelegate.java [modify] https://crrev.com/2665a13c2c0c90a5d9f8ec1215a8af58b0df85c8/ui/android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java
,
Jul 24 2017
,
Sep 19 2017
Is there more work for this or can it be closed?
,
Sep 19 2017
The points torne@ mentioned in c#4 still need to be resolved
,
Mar 1 2018
This fell off my radar, I should probably finish this. Not entirely sure how to get rid of GetLibraryProcessType() on the native side without adding something else that basically does the same thing (i.e. are we WebView or Chrome?). torne mentioned having separate entry points above but it's not clear to me how that would work. Don't we need the monochrome lib to have a single exported JNI_OnLoad()?
,
Mar 1 2018
Monochrome's JNI_OnLoad should be a minimal implementation that only does the important common things, and all the rest of the native initialisation code should be moved to two separate normal JNI functions that can be called by the Java code. This approach could just be used for Chrome/WebView as well. JNI_OnLoad in all cases could *only* be responsible for JNI registration, which would make it a no-op for webview/monochrome. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by estevenson@chromium.org
, Dec 16 2016