android-browser-helper: NullPointerException in com.google.androidbrowserhelper.trusted.TwaLauncher.launchWhenSplashScreenReady

Describe the bug We have recently upgraded from the google custom tabs client to android browser helper and notice a significant number of crashes, the highest being related to a NullPointerException from com.google.androidbrowserhelper.trusted.TwaLauncher.launchWhenSplashScreenReady

To Reproduce Steps to reproduce the behavior:

  1. Download Badoo Lite from play store using one of the mentioned devices in screenshot.
  2. Launch the app

Errors are recorded when the app launches, play console has this stack trace from a Motorola Moto C Plus, but see also attached affected devices):

java.lang.NullPointerException: 
  at androidx.browser.trusted.TrustedWebActivityIntentBuilder.build (TrustedWebActivityIntentBuilder.java:220)
  at com.google.androidbrowserhelper.trusted.TwaLauncher.launchWhenSplashScreenReady (TwaLauncher.java:229)
  at com.google.androidbrowserhelper.trusted.TwaLauncher.lambda$launchWhenSessionEstablished$3$TwaLauncher (TwaLauncher.java:217)
  at com.google.androidbrowserhelper.trusted.-$$Lambda$TwaLauncher$Pgq1RErTrlHE2hqdSd7zUQR6Yz4.run (lambda)
  at com.google.androidbrowserhelper.trusted.splashscreens.PwaWrapperSplashScreenStrategy.onSplashImageTransferred (PwaWrapperSplashScreenStrategy.java:202)
  at com.google.androidbrowserhelper.trusted.splashscreens.PwaWrapperSplashScreenStrategy.lambda$configureTwaBuilder$0$PwaWrapperSplashScreenStrategy (PwaWrapperSplashScreenStrategy.java:195)
  at com.google.androidbrowserhelper.trusted.splashscreens.-$$Lambda$PwaWrapperSplashScreenStrategy$w9o5iqMEy62ZZ2i_sMAmRiQ7IGw.onFinished (lambda)
  at com.google.androidbrowserhelper.trusted.splashscreens.SplashImageTransferTask$1.onPostExecute (SplashImageTransferTask.java:144)
  at com.google.androidbrowserhelper.trusted.splashscreens.SplashImageTransferTask$1.onPostExecute (SplashImageTransferTask.java:91)
  at android.os.AsyncTask.finish (AsyncTask.java:660)
  at android.os.AsyncTask.-wrap1 (AsyncTask.java)
  at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:677)
  at android.os.Handler.dispatchMessage (Handler.java:110)
  at android.os.Looper.loop (Looper.java:203)
  at android.app.ActivityThread.main (ActivityThread.java:6251)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1075)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:936)

Expected behavior App launches without the NullPointerException

Did this ever used to work Similar error happened with google tabs client.

Screenshots Screenshot 2020-06-08 at 12 56 24 Screenshot 2020-06-08 at 13 04 36

Code Snippets Splash screen strategy is being set with this code:

this.mSplashScreenStrategy = new PwaWrapperSplashScreenStrategy(this, this.mMetadata.splashImageDrawableId, this.getColorCompat(this.mMetadata.splashScreenBackgroundColorId), this.getSplashImageScaleType(), this.getSplashImageTransformationMatrix(), this.mMetadata.splashScreenFadeOutDurationMillis, this.mMetadata.fileProviderAuthority);

These all have values except for transformation matrix which is null.

Smartphone (please complete the following information):

  • Device: Motorola Moto C Plus
  • OS: Android 8.1
  • Browsers Installed: Chrome
  • Browser Versions: Don’t know
  • android-browser-helper library version: 1.1.0

Additional context Badoo Lite is released on the play store for low end devices as an alternative for the native android app.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 41 (19 by maintainers)

Commits related to this issue

Most upvoted comments

We have released 1.4.0-alpha01 yesterday with the fix for this issue included:

    implementation 'com.google.androidbrowserhelper:androidbrowserhelper:1.4.0-alpha01'

androidx.browser-1.3.0 has finally hit stable and we have released version 2.1.0 of android-browser-helper, which depends on the new androidx.browser version. This bug shouldn’t happen anymore when using that. To use it, update the app’s build.gradle as below:

implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.1.0'

Thanks for the patience for this issue to be resolved.

Totally clear, @andreban thank you for the explanation ❤️

20 perfect launches on the Samsung A10 also.

@andreban I think we have a winner, ran it 20 times, no issues, splash screen went away every time and didn’t see a url bar once. I’ll try it on my Samsung A10 and will check it with push notifications. So far it looks like best version yet.

Battery saver is off in android settings. Under Location settings it says Mode Battery saving though, but in Battery settings it has Battery saver Off / Never turn on automatically. Can’t see any memory optimizer setting.