Guard against Gio's null-view detach event (recents-wipe SIGABRT) #1

Closed
gmp wants to merge 0 commits from fix/recents-wipe-jni-null-view into master
Owner

Gio's GioView.onDestroyView sends ViewEvent{View: 0} as its detach signal when the view is destroyed - i.e. the activity going away on a recents-wipe. An app that forwards the event to Enable() passes a zero view through to registerFragment, whose GetObjectClass(null) aborts the process:

A fatal error has been detected by the Java Runtime Environment:
Internal Error (cgo/go.go:942), pid=27286, tid=0x0000b40562753b00
Detected error: JNI DETECTED ERROR IN APPLICATION: java_object == null
in call to GetObjectClass
from void registerFragment(_jobject*)

Reproduced on a Pixel 9 Pro (Android 17) with the equivalent app (pad): swiping the app away in recents crashes it. The pinned gio version (2020-08) sends the same empty ViewEvent{View: 0} from Java_org_gioui_GioView_onDestroyView.

Enable() now returns early on a zero view so all callers are covered even if they forward the event unfiltered, and registerFragment null-checks as defense in depth. Note: any app that also uses the view ref for other JNI calls should apply the same View == 0 check in its own event handler.

Same fix as pad (gmp/pad@fdbffc9), verified there on-device: recents swipe closes cleanly, no tombstone.

Gio's `GioView.onDestroyView` sends `ViewEvent{View: 0}` as its detach signal when the view is destroyed - i.e. the activity going away on a recents-wipe. An app that forwards the event to `Enable()` passes a zero view through to `registerFragment`, whose `GetObjectClass(null)` aborts the process: A fatal error has been detected by the Java Runtime Environment: Internal Error (cgo/go.go:942), pid=27286, tid=0x0000b40562753b00 Detected error: JNI DETECTED ERROR IN APPLICATION: java_object == null in call to GetObjectClass from void registerFragment(_jobject*) Reproduced on a Pixel 9 Pro (Android 17) with the equivalent app (pad): swiping the app away in recents crashes it. The pinned gio version (2020-08) sends the same empty `ViewEvent{View: 0}` from `Java_org_gioui_GioView_onDestroyView`. `Enable()` now returns early on a zero view so all callers are covered even if they forward the event unfiltered, and `registerFragment` null-checks as defense in depth. Note: any app that also uses the view ref for other JNI calls should apply the same `View == 0` check in its own event handler. Same fix as pad (gmp/pad@fdbffc9), verified there on-device: recents swipe closes cleanly, no tombstone.
gmp added 1 commit 2026-08-20 22:54:17 -04:00
Gio's GioView.onDestroyView sends ViewEvent{View: 0} as its detach
signal when the view is destroyed — i.e. the activity going away on a
recents-wipe. An app that forwards the event to Enable() passes a zero
view through to registerFragment, whose GetObjectClass(null) aborts the
process (JNI DETECTED ERROR: java_object == null in call to
GetObjectClass).

Enable() now returns early on a zero view so all callers are covered
even if they forward the event unfiltered, and registerFragment
null-checks as defense in depth. Same fix as pad (fdbffc9); verified
there on a Pixel 9 Pro / Android 17 where the recents swipe used to
crash the app.
gmp closed this pull request 2026-08-21 06:56:56 -04:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gmp/ble#1
No description provided.