-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Replace +load initializers with __attribute__((constructor)) functions #1425
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,9 @@ @implementation ASTipsController | |
|
||
#pragma mark - Singleton | ||
|
||
+ (void)load | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we're on this, can we wrap this initializer in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the code in this file is wrapped in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Good call. I missed that. |
||
__attribute__((constructor)) static void ASLoadTipsControllerNotification(void) | ||
{ | ||
[NSNotificationCenter.defaultCenter addObserver:self.shared | ||
[NSNotificationCenter.defaultCenter addObserver:ASTipsController.shared | ||
selector:@selector(windowDidBecomeVisibleWithNotification:) | ||
name:UIWindowDidBecomeVisibleNotification | ||
object:nil]; | ||
|
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.
Agree that using static attribute initializer is the best option here.
We should update the documentation of
-[ASConfigurationDelegate textureDidInitialize]
(here) to state that it's called "pre-main" instead of in a+load
method.@Adlai-Holler @maicki Do you know if
-textureDidInitialize
is useful for any clients? If it can be removed, and if we can shut downASExperimentalLayerDefaults
experiment (i.e gatherallowsGroupOpacityFromUIKitOrNil
andallowsEdgeAntialiasingFromUIKitOrNil
on demand instead), then we can removeASInitializeFrameworkMainThread()
completely and reduce pre-main time of every app by a bit.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.
Thanks for catching that, @nguyenhuy! I noticed that comment when I was debugging this but forgot to update it with this patch. I'll push an update in a minute.
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.
Awesome, thanks!
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.
We do rely on
-textureDidInitialize
currently so I don't want to get rid of it right now but let me think of how we can remove our reliance on it.