Sometimes application code will init objects that inadvertently access UIScreen.main, usually for UIScreen.main.scale. Since we never update the screen scale after init, we can cache the last known value and use it internally for our calculations. This will reduce the number of crashes we see without affecting behaviour.
Please check if the PR fulfills these requirements
[ ] Self-review: I am confident this is the simplest and clearest way to achieve the expected behaviour
[ ] There are no dependencies on other PRs or I have linked dependencies through Zenhub
[ ] The commit messages are clean and understandable
[ ] Tests for the changes have been added (for bug fixes / features)
Fixes crashes when accessing a deinited UIScreen
Type of change: Bug fix
Motivation (current vs expected behavior)
Sometimes application code will init objects that inadvertently access
UIScreen.main
, usually forUIScreen.main.scale
. Since we never update the screen scale after init, we can cache the last known value and use it internally for our calculations. This will reduce the number of crashes we see without affecting behaviour.Please check if the PR fulfills these requirements