foobnix / LibreraReader

Book Reader for Android
http://librera.mobi
Other
2.72k stars 297 forks source link

Starting Text-To-Speech (TTS) on a new install crashes the app unless you open and start it from the full TTS menu #1201

Closed Nitrousoxide closed 7 months ago

Nitrousoxide commented 7 months ago

Summary

With all the reinstalling I was doing for the ToC cache issue I noticed a TTS issue as well. It will crash if you attempt to open start TTS the first time on an install if you don't do so using the full TTS menu. I believe you may also need to switch the book as well? Though I'm not entirely sure on that point.

Steps to replicate:

  1. Install the app. It can be a totally fresh install or one which has previous user data. I don't believe it matters, though with the presence of previous user data (and thus settings) you're more likely to be in "Accessibility mode" and thus have the TTS control always visible at the bottom.
  2. Make sure the accessibility mode is on to always have the tts control active.
  3. Open a book and hit the TTS control at the bottom.
  4. Phone will vibrate then app will crash

I assume this is due to some first-run TTS settings not being present when the accessibility mode is used to activate the TTS and thus cause a crash. Flipping books and then using the full TTS menu seems to fix it, and then you can return to the book where the crash occurred and use the accessibility mode TTS controls just fine. Other files also don't require first opening the full TTS controls.

Images to reference the controls I am talking about:

Accessibility Mode Controls: Screenshot_20231202-072524

Full TTS Controls: Screenshot_20231202-072555

foobnix commented 7 months ago

Please install the beta.librera.mobi app, it should be fixed

Nitrousoxide commented 7 months ago

I was still able to replicate it on the beta for 8.9.82.

I started up adb to capture the error log:

12-02 09:19:02.969 25691 25691 E AndroidRuntime: FATAL EXCEPTION: main
12-02 09:19:02.969 25691 25691 E AndroidRuntime: Process: com.foobnix.pro.pdf.reader, PID: 25691
12-02 09:19:02.969 25691 25691 E AndroidRuntime: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{7fb0288 u0 com.foobnix.pro.pdf.reader/com.foobnix.tts.TTSService}
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2104)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2075)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2369)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:205)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:294)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8177)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
12-02 09:19:02.969 25691 25691 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Here is the epub I was using to test too if that's helpful https://cloud.nitrogendioxide.xyz/s/ps6d6ebJR6TB28F

Nitrousoxide commented 7 months ago

Also here is a video of how I get the crash.

https://cloud.nitrogendioxide.xyz/s/mEgFsx4Xkx4i9yY

foobnix commented 7 months ago

@Nitrousoxide please check new beta.librera.mobi

Nitrousoxide commented 7 months ago

@foobnix 8.9.84 seems to be working fine with no crash.