Skip to content

NullPointerException when calling ViewCompat.getRootWindowInsets(rootView).isVisible #51

@tobias-kuendig

Description

@tobias-kuendig

Bug Report

Capacitor Version

  @capacitor/ios: not installed
  @capacitor/cli: 8.0.2
  @capacitor/android: 8.0.2
  @capacitor/core: 8.0.2

Platform(s)

Android

Current Behavior

I've received the following NullPointerException when my app is being closed. It does only happen sporadically. It seems like the ViewCompat.getRootWindowInsets(rootView).isVisible call can return null under certain circumstances. This null value must be handled.

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.core.view.WindowInsetsCompat.isVisible(int)' on a null object reference
    at com.capacitorjs.plugins.keyboard.Keyboard$1.onEnd(Keyboard.java:109)
    at androidx.core.view.WindowInsetsAnimationCompat$Impl21.dispatchOnEnd(WindowInsetsAnimationCompat.java:956)
    at androidx.core.view.WindowInsetsAnimationCompat$Impl21$Impl21OnApplyWindowInsetsListener$2.onAnimationEnd(WindowInsetsAnimationCompat.java:857)
    at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
    at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1242)
    at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1484)
    at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
    at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
    at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:965)
    at android.view.Choreographer.doCallbacks(Choreographer.java:791)
    at android.view.Choreographer.doFrame(Choreographer.java:722)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7386)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

Additional Context

There are multiple calls to the isVisible method throughout the class.

The exception was recorded under Android 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions