Skip to content
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

Avoid creating multiple instances of DefaultTheme. #380

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mc-public
Copy link

The UIColor(named:in:compatibleWith:) initializer method loads colors from the module's resource file on a global queue. Classes like LineController in the Runestone project create multiple instances of DefaultTheme during initialization, causing a large number of UIColor construction tasks to be allocated on the global queue. This can lead to noticeable lag, especially for larger texts, and prevent the editor from properly releasing memory when exiting.

The changes made in this pull request are as follows:

extension DefaultTheme {
    public static let share = DefaultTheme()
}

Then replace most occurrences of DefaultTheme() in the framework with DefaultTheme.share.

Fixed the issue where the default theme was always recreated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant