question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of PixelUtil causes crash on the app start

See original GitHub issue

Description

We got lots of following crash on our app at production:

Caused by java.lang.NullPointerException: Attempt to read from field 'float android.util.DisplayMetrics.density' on a null object reference
       at android.util.TypedValue.applyDimension(TypedValue.java:391)
       at com.facebook.react.uimanager.PixelUtil.toPixelFromDIP(PixelUtil.java:18)
       at com.swmansion.rnscreens.ScreenStackFragment.<clinit>(ScreenStackFragment.java:64)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at androidx.fragment.app.Fragment.instantiate(Fragment.java:548)
       at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
       at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:390)
       at androidx.fragment.app.FragmentStateManager.<init>(FragmentStateManager.java:74)
       at androidx.fragment.app.FragmentManager.restoreSaveState(FragmentManager.java:2454)
       at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:196)
       at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:287)
       at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:115)
       at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)

It is caused by usage of PixeUtil to assign static variable at start.

My commit may fix this. Since I don’t know how to reproduce this on my test devices, I will test on production app and will open a pull request.

Package versions

  • React: 16.9.0, 17.0.1
  • React Native: 0.63.2, 0.64.2
  • React Native Screens: 3.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sercandcommented, Aug 1, 2021

@WoLewicki PR doesn’t affect the changing shadow hidden/shown setting. I believe we can merge the PR.

1reaction
sercandcommented, Jul 22, 2021

@WoLewicki I don’t know to reproduce the crash. The app just crashes on start before loading any screen. It happens on different android versions and different vendors randomly. I tested it on production because I don’t know to reproduce it and we no longer see the crash.

Our apps don’t use toolbar and I will check it later to confirm if it is still working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do my apps keep crashing on Android, How to fix it
There can be multiple reasons why apps to freeze or crash, especially when you ... Android apps can build up large caches based...
Read more >
Detect and diagnose crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >
Why Do My Apps Keep Crashing on Android? - Avast
Do your Android apps keep crashing? Discover why and learn how to prevent Android apps crashing and freezing by following these methods.
Read more >
How to Fix Crashing Apps on an iPhone or Android?
Fix App Crashes on your Apple iPhone or Android smartphone. Kill the App; Restart the Phone; Update the App; Official Support; Use Bugfender!...
Read more >
Fix an Android device that's restarting or crashing
Try the following steps if your phone has any of these problems: Randomly reboots or restarts; Shuts down without restarting; Restarts constantly: Go...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found