High: Coroutine leaks, unsafe InputStream, and cache never invalidated #27
Labels
No labels
blocked:needs-attention
blocked:needs-decision
blocked:needs-human
blocked:verify-failed
bug
chore
critical
decompose
feature-request
high
in-progress
medium
quality
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/activity-book-app#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Findings
H1:
CoroutineScope(Dispatchers.Main)created in ColoringActivity, GalleryActivity, and StoryActivity but never cancelled inonDestroy(). Coroutines outlive the Activity, crash with "View not attached to window manager", and leak the entire Activity context. Fix: uselifecycleScopeor cancel inonDestroy().H2:
StoryRepository.ktreads assets usingInputStream.available()which is not guaranteed to return total file size (returns 0 for compressed assets).read(buffer)may read fewer bytes than the buffer size. Can produce truncated JSON. Fix: usebufferedReader().readText().H3:
cachedStoriesandcachedChaptersnever invalidated. If story data changes (downloaded update), app needs process restart.Affected files
android/app/src/main/java/com/storyplay/activitybook/ui/ColoringActivity.ktandroid/app/src/main/java/com/storyplay/activitybook/ui/GalleryActivity.ktandroid/app/src/main/java/com/storyplay/activitybook/ui/StoryActivity.ktandroid/app/src/main/java/com/storyplay/activitybook/data/StoryRepository.kt