General fixes (#19)

* fix OOM crash by refactoring EpubImage to use lazy loading

- Removed raw image ByteArray from EpubImage data class to prevent OutOfMemoryErrors on large books.
- Updated EpubParser and MobiParser to only store image paths in the EpubBook object.
- Images are now loaded on-demand from disk via file URIs in WebView and Coil, reducing initial heap allocation.

* fix(tts): resolve OutOfMemoryError by removing large strings from state bundle

- Removed 'currentText' from the TtsState bundle inside MediaSession custom layout.
- Updated TtsController to retrieve the current text chunk via MediaItem metadata.
- This prevents heap exhaustion caused by high-frequency serialization of large text strings during word tracking and polling updates.
This commit is contained in:
Aryan 2026-03-01 23:24:26 +05:30 committed by GitHub
parent a81df6921d
commit d6837aa4df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 47 deletions

View file

@ -236,7 +236,7 @@ class TtsController(context: Context) : Player.Listener {
isPlaying = controller.isPlaying,
isLoading = isLoading,
currentText = if (isPlaybackActive) {
currentTextFromMediaItem ?: customState.getString("currentText")
currentTextFromMediaItem
} else {
if (isLoading) currentState.currentText else null
},

View file

@ -615,7 +615,6 @@ class TtsPlaybackManager(
private fun createStateButton(state: TtsState): CommandButton {
val bundle = Bundle().apply {
putBoolean("isLoading", state.isLoading)
putString("currentText", state.currentText)
putString("errorMessage", state.errorMessage)
putString("speakerId", state.speakerId)
putBoolean("sessionEndedByStop", state.sessionEndedByStop)