-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a crash where fonts randomly become unavailable #1354
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy crap! Awesome job digging into this😄🎉🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤞 🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that's interesting! Any idea why it doesn't crash in Legendary?
No idea 🤷 mystery |
@Breiby Figured out why legendary is working. There we do a double registering of fonts, so we do it in FinniversKit, but also add the fonts as "Fonts provided by application" to Info.plist. So legendary would fallback on that one and not crash. So seems like I might not have to merge this PR, but rather fix it on the other side (add fonts to the main project for FINN NMP and Tori). |
Wow, nice catch! 💪 |
Closing this one, we found an alternative way to solve it. |
Why?
We have a crash in Tori and FINN NMP related to fonts. The problem is that some fonts suddenly "disappear" from memory a while after having been successfully loaded on app startup, so our force unwrap of the FINN font will crash the app.
What?
We found a consistent way to reproduce this:
I found this thread of others experiencing the same issue. The last post includes a fix, where you use another method for registering fonts based on URL. Currently we are using this method to register fonts:
CTFontManagerRegisterGraphicsFont
, but the fix is to switch toCTFontManagerRegisterFontsForURL
, where you are able to specify a scope.There's a scope called
.process
which means the font will be available for the lifetime of "the process" which registered it, e.g. it needs to be registered once after every restart of the app, as we already do.After having changed to
CTFontManagerRegisterFontsForURL
, the app does not crash anymore when following the steps above, so it seems to fix it. 🤞Version Change
Minor.