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

Ensure macOS apps pick up new icons after an update #1766

Merged
merged 5 commits into from
May 2, 2024

Conversation

freakboy3742
Copy link
Member

With the switch to Toga using the binary's icon at runtime, a new bug emerges - macOS caches app icons. When using the app template, and you change the app icon, the app bundle on the filesystem will be updated, but starting the app will show the old icon.

If you re-create the app, the new icon is displayed.

The cache key appears to be the modification time on the .app bundle itself; if you touch the bundle as part of an update, the new icon is loaded.

This didn't affect the Xcode template because every run is a new build, which implicitly touches the .app bundle.

This PR force touches the .app bundle on the macOS backends to ensure that the icon cache is busted.

Includes a coupe of cosmetic whitespace updates for good measure.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@freakboy3742 freakboy3742 requested a review from mhsmith May 2, 2024 02:58
@mhsmith mhsmith merged commit a8aa076 into beeware:main May 2, 2024
51 checks passed
@mhsmith
Copy link
Member

mhsmith commented May 2, 2024

FYI: I've seen something similar on Android, and I never discovered any workaround other than uninstalling and reinstalling the app. But I think it only affected the icon visible in the apps list in the launcher, not the running app itself. It's possible this has been fixed on newer Android versions.

Comment on lines 688 to 691
self.logger.warning(
"Splash screens are now configured based on the icon. "
"The splash configuration will be ignored."
"\nSplash screens are now configured based on the icon. "
"The splash configuration will be ignored.\n"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an FYI, as a consequence of str.splitlines() in Log(), a single trailing newline is effectively ignored. However, a trailing newline in the output text can be achieved with two trailing newlines in the string.

>>> "\nline of text\n".splitlines()
['', 'line of text']
>>> "\nline of text\n\n".splitlines()
['', 'line of text', '']

Same as the "extra" newline in the multiline strings.

>>> """line 1
... line 2
... line 3
... 
... """
'line 1\nline 2\nline 3\n\n'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - I'd completely forgotten we'd made this change. I've cleaned this up in #1769.

It would be nice if there was a way to automate catching stylistic regressions like this, but I'm not sure I have any ideas on how we'd do that.

@freakboy3742 freakboy3742 deleted the macos-icon-flush branch May 2, 2024 22:15
@freakboy3742 freakboy3742 mentioned this pull request May 2, 2024
4 tasks
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.

3 participants