Closed Bug 959237 Opened 10 years ago Closed 10 years ago

Define GetJNIEnv and GetJNIForThread as infallible

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 29

People

(Reporter: jchen, Assigned: jchen)

References

Details

Attachments

(2 files)

GetJNIEnv and GetJNIForThread are fundamental operations that have no reason to fail. If they do fail, Fennec likely won't run correctly, and we probably have a bug (e.g. using JNI before initialization or after termination). Defining them as infallible means callers don't have to check for null being returned, and real bugs mentioned before get more visibility when we do crash because of unexpected failures.

There are some special cases with tests where we don't have a Java frontend (xpcshell tests, C++ tests, e10s tests), and these special cases can be whitelisted.
Currently when either of these methods fail, we log something and rely on the calling code to null check. Since these failures are serious and likely unrecoverable, it's better to define these methods as infallible and just crash if they do fail (won't happen if things are working correctly).
Attachment #8359311 - Flags: review?(blassey.bugs)
For certain tests, the AndroidBridge is not initialized, but some GeckoAppShell functions are still called indirectly. For now, this patch adds checks to skip these calls if there's no AndroidBridge.
Attachment #8359312 - Flags: review?(blassey.bugs)
Comment on attachment 8359311 [details] [diff] [review]
Define GetVM, GetJNIEnv, and GetJNIForThread as infallible (v1)

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

::: dom/plugins/base/nsPluginInstanceOwner.cpp
@@ +1572,3 @@
>        env->IsSameObject(view, (jobject)sFullScreenInstance->mInstance->GetJavaSurface())) {
>      sFullScreenInstance->ExitFullScreen();
>    } 

fix this whitespace

::: gfx/thebes/nsSurfaceTexture.cpp
@@ +29,2 @@
>  
>    

fix this white space
Attachment #8359311 - Flags: review?(blassey.bugs) → review+
Comment on attachment 8359312 [details] [diff] [review]
Add AndroidBridge::HasEnv checks (v1)

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

::: ipc/glue/MessagePump.cpp
@@ +105,5 @@
>      // This processes messages in the Android Looper. Note that we only
>      // get here if the normal Gecko event loop has been awoken above.
>      // Bug 750713
> +    if (MOZ_LIKELY(AndroidBridge::HasEnv())) {
> +        did_work |= GeckoAppShell::PumpMessageLoop();

put the HasEnv() check in PumpMessageLoop()
Attachment #8359312 - Flags: review?(blassey.bugs) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/ae1c7e26a97d
https://hg.mozilla.org/integration/mozilla-inbound/rev/3f69ca51a4e8


(In reply to Brad Lassey [:blassey] (use needinfo?) from comment #4)
> Comment on attachment 8359312 [details] [diff] [review]
> Add AndroidBridge::HasEnv checks (v1)
> 
> Review of attachment 8359312 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: ipc/glue/MessagePump.cpp
> @@ +105,5 @@
> >      // This processes messages in the Android Looper. Note that we only
> >      // get here if the normal Gecko event loop has been awoken above.
> >      // Bug 750713
> > +    if (MOZ_LIKELY(AndroidBridge::HasEnv())) {
> > +        did_work |= GeckoAppShell::PumpMessageLoop();
> 
> put the HasEnv() check in PumpMessageLoop()

PumpMessageLoop() is autogenerated so the check had to be outside of it.
https://hg.mozilla.org/mozilla-central/rev/ae1c7e26a97d
https://hg.mozilla.org/mozilla-central/rev/3f69ca51a4e8
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 29
Depends on: 963242
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: