Closed Bug 1192082 Opened 9 years ago Closed 9 years ago

Let nsAppShell manage JNI/AndroidBridge lifetime

Categories

(Core Graveyard :: Widget: Android, defect)

All
Android
defect
Not set
normal

Tracking

(firefox43 fixed)

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: jchen, Assigned: jchen)

References

Details

Attachments

(6 files)

I think nsAppShell should manage initializing and deinitializing JNI and AndroidBridge. A lot of AndroidBridge will likely be merged into nsAppShell anyways.
Instead of letting AndroidBridge be constructed separately, we'll let
nsAppShell construct AndroidBridge. We'll also make AndroidBridge fetch
the init arguments from GeckoThread.
Attachment #8644698 - Flags: review?(snorp)
AndroidBridge needed some arguments during its initialization. We'll
provide those arguments in GeckoThread, which AndroidBridge will access.
Attachment #8644699 - Flags: review?(snorp)
Merge all the init code into AndroidBridge constructor and
AndroidBridge::ConstructBridge; merge all the deinit code into
AndroidBridge destructor and AndroidBridge::DeconstructBridge.

In particular, the SetMainThread call is obsolete and removed.
Attachment #8644700 - Flags: review?(snorp)
First we need to set the Gecko thread JNIEnv* in nsAndroidStartup, but
after that we can initialize and deinitialize the rest of JNI, including
AndroidBridge, in GeckoAppShell. This makes nsAppShell control the
AndroidBridge lifetime. Over time, parts of the AndroidBridge
functionality will be migrated to nsAppShell.
Attachment #8644701 - Flags: review?(snorp)
Comment on attachment 8644698 [details] [diff] [review]
Get rid of GeckoAppShell.nativeInit (v1)

Review of attachment 8644698 [details] [diff] [review]:
-----------------------------------------------------------------

Yay! Are we sure we can construct it early enough?
Attachment #8644698 - Flags: review?(snorp) → review+
Comment on attachment 8644699 [details] [diff] [review]
Expose AndroidBridge arguments through GeckoThread (v1)

Review of attachment 8644699 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/android/GeneratedJNIWrappers.cpp
@@ +775,5 @@
>  
> +constexpr char GeckoThread::ClsLoader_t::name[];
> +constexpr char GeckoThread::ClsLoader_t::signature[];
> +
> +auto GeckoThread::ClsLoader() -> mozilla::jni::Object::LocalRef

My understanding is that the 'auto foo() -> return_type_t' syntax is only better if you declare the return type within the function. Here that's not the case, and it seems harder to read. *shrug*
Attachment #8644699 - Flags: review?(snorp) → review+
Attachment #8644700 - Flags: review?(snorp) → review+
Comment on attachment 8644701 [details] [diff] [review]
Iniialize/deinitialize JNI in nsAppShell (v1)

Review of attachment 8644701 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/android/nsAppShell.cpp
@@ +152,5 @@
> +
> +    if (!jni::IsAvailable()) {
> +        return;
> +    }
> +    AndroidBridge::ConstructBridge();

We should probably construct the bridge first thing, in case the PowerManagerService above needs it.
Attachment #8644701 - Flags: review?(snorp) → review+
Forgot to include this patch which was meant to address comment 8.
I will push it as a follow up.
Attachment #8647629 - Flags: review+
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: