zoontek / react-native-bootsplash

πŸš€ Show a splash screen during app startup. Hide it when you are ready.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash on Android <= 9 - Attempt to invoke virtual method Drawable.isProjected() on a null object reference - solved in 5.1.2

delphinebugner opened this issue Β· comments

Before submitting a new issue

  • I tested using the latest release of the library, as maybe the bug has been already fixed.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

Hi! πŸ‘‹ I open this issue for future reference, as the crash I had was fixed in the newest version of the lib.

My intention is to close it after creating it - but if someone encountered the same crash, he will know what to do.

Description

I was using version 5.1.0 of the lib on RN 0.73.2 (old archi). I used a brand, but removed it when changing the design of the splashscreen:

    <style name="BootTheme" parent="Theme.BootSplash.EdgeToEdge">
        <item name="bootSplashBackground">@color/bootsplash_background</item>
        <item name="bootSplashLogo">@drawable/bootsplash_logo</item>
-       <item name="bootSplashBrand">@drawable/bootsplash_brand</item>
        <item name="postBootSplashTheme">@style/AppTheme</item>
    </style>
    <!-- Also removed bootsplash_brand.png files-->

I forgot to test the changes on old Android version (6, 7, 8 and 9), and realized only in production that a null pointer exception occurred with message Attempt to invoke virtual method 'boolean android.graphics.drawable.Drawable.isProjected()' on a null object reference.

Fix

  • Reverting to the previous splashscreen with the brand fixed the crash on old Android.
  • Upgrading the lib to 5.4.2 also fixed it. πŸŽ‰
    • I think it's thanks to commit #511. I quickly check by reverting it locally and I had the crash again on 5.4.2. It relates to some transparent placeholder when there is no brand, so it makes sense!

Full Stack Trace

2024-03-04 12:14:04.469 18275-18275 AndroidRuntime          com.tf1.mobilenews.staging.debug     E  FATAL EXCEPTION: main
Process: com.tf1.mobilenews.staging.debug, PID: 18275
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.drawable.Drawable.isProjected()' on a null object reference
	at android.graphics.drawable.LayerDrawable.isProjected(LayerDrawable.java:417)
	at android.view.View.invalidateInternal(View.java:16438)
	at android.view.View.invalidate(View.java:16398)
	at android.view.View.setFrame(View.java:20819)
	at com.android.internal.policy.DecorView.setFrame(DecorView.java:593)
	at android.view.View.layout(View.java:20669)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2792)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2319)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
	at android.view.Choreographer.doCallbacks(Choreographer.java:761)
	at android.view.Choreographer.doFrame(Choreographer.java:696)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6669)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Library version

5.1.0

Environment info

System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 212.00 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/Library/Caches/fnm_multishells/85964_1709551028433/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.3
    path: ~/Library/Caches/fnm_multishells/85964_1709551028433/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/delphinebugner/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 3.1.0
    path: /Users/delphinebugner/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

No steps yet, as the bug is already fixed!

Reproducible sample code

No reproducible code, but if the maintainer want to further investigate, I can try to push a minimal example!

Closed as is has been fixed in version 5.4.2 (I think with #511)

Thanks a lot @delphinebugner, this will help persons searching for a similar issue