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

fix memory leak in CompositeWithOpaqueBackground #4150

Merged
merged 1 commit into from
Dec 10, 2023
Merged

Conversation

connyduck
Copy link
Collaborator

@connyduck connyduck commented Dec 7, 2023

Found with Leak canary: The transformation ends up in Glide's memory cache and leaks whole Activities through the view -> context reference.

This fixes the problem by removing the background detection logic (so the view reference is no longer needed) and setting the background directly instead. Looks exactly as before.

nikclayton added a commit to nikclayton/pachli-android that referenced this pull request Dec 9, 2023
Quoting @connyduck in tuskyapp/Tusky#4150:

"""
The transformation ends up in Glide's memory cache and leaks whole
Activities through the view -> context reference.

This fixes the problem by removing the background detection logic (so
the view reference is no longer needed) and setting the background
directly instead. Looks exactly as before.
"""
nikclayton added a commit to pachli/pachli-android that referenced this pull request Dec 9, 2023
Quoting @connyduck in tuskyapp/Tusky#4150:

"""
The transformation ends up in Glide's memory cache and leaks whole
Activities through the view -> context reference.

This fixes the problem by removing the background detection logic (so
the view reference is no longer needed) and setting the background
directly instead. Looks exactly as before.
"""

Co-authored-by: Konrad Pozniak <[email protected]>
@connyduck connyduck merged commit db27186 into develop Dec 10, 2023
3 checks passed
@connyduck connyduck deleted the fix_memory_leak branch December 10, 2023 06:37
connyduck added a commit that referenced this pull request Dec 10, 2023
…eton (#4153)

Another fix for a memory leak. This one is not as big as #4150, but
still worth fixing for memory constrained devices imo.
The `DrawerImageLoader` implementation (a global singleton) references a
member of the `MainActivity`, causing the whole activity to leak.

This weird construct was introduced in #1989 to fix a crash, but I think
since we migrated to coroutines it is no longer necessary because all
calls get correctly cancelled. I tried reproducing the crash but could
not, so I'm pretty sure it is fine. I would appreciate it if someone
else could try it as well though.

(The crash could be reproduced on slow internet, when
`onFetchUserInfoSuccess` was called while the activity was being
destroyed, causing Glide to crash the app because it can't use destroyed
activities. `onFetchUserInfoSuccess` is now no longer called in this
case because it is inside a `lifecycleScope.launch` block.)
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