chickendude / Natibo

Breathe new life into your Glossika PDF/MP3 courses!
The Unlicense
26 stars 3 forks source link

App crashes when selecting course starting point #33

Closed flackbash closed 1 year ago

flackbash commented 5 years ago

When selecting a course starting point before starting the first session, the app crashes with the error:

java.lang.RuntimeException: Unable to start service ch.ralena.natibo.service.StudySessionService@dc299 with Intent { cmp=ch.ralena.natibo.debug/ch.ralena.natibo.service.StudySessionService }: java.lang.ArrayIndexOutOfBoundsException: Out of range  in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp line 135(requested: 0 valid: 0)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3647)
        at android.app.ActivityThread.-wrap21(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1748)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6673)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
     Caused by: java.lang.ArrayIndexOutOfBoundsException: Out of range  in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp line 135(requested: 0 valid: 0)
        at io.realm.internal.OsList.nativeGetRow(Native Method)
        at io.realm.internal.OsList.getUncheckedRow(OsList.java:48)
        at io.realm.RealmModelListOperator.get(RealmList.java:1431)
        at io.realm.RealmList.get(RealmList.java:413)
        at ch.ralena.natibo.object.Day.getCurrentSentenceGroup(Day.java:73)
        at ch.ralena.natibo.service.StudySessionService.loadSentence(StudySessionService.java:161)
        at ch.ralena.natibo.service.StudySessionService.onStartCommand(StudySessionService.java:114)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3630)

I also can't get the selection of a starting point to work in general. It just always seems to start from where I left off, even though it says "Sentence set to book X sentence Y".

chickendude commented 5 years ago

It'll start after the next session, if you've already opened it then it's created that day's reviews already and you'll have to wait until the next day's sentences are built. It's also possible that something broke when i made the changes to support triangulation courses, to be honest i haven't tested it out since. I'll take another look at it when i get the chance, it should be pretty easy to reproduce. Thanks for reporting it!

chickendude commented 5 years ago

I just tried this and am unable to reproduce the crash, can you still reproduce this? If you could provide a bit more info that'd be great.

Setting the sentence also seems to work for me just fine, what if i check if a new session has been started and give you the option to reset that session starting from the new sentence point?

jubalh commented 5 years ago

Just tried this, works for me now.

flackbash commented 5 years ago

The bug still exists. But I found the more specific scenario in which the bug occurs. I haven't had a look at the code, but from the outside it presents itself like this:

When I add a book to the course, there are three "slots" in which a book can be. The book you add first occupies the first slot, the second book the second, the third book, naturally, the third slot. This shows itself in the change starting point fragment: The order of the books there will be the order in which I added books to the course and not the intuitive order (first F1 then F2 and then F3). If the slots are occupied by all three books F1 to F3 in the natural order, no error occurs. But if I change the order, let's say F2 in the first slot, then F3, then F1, and then select a sentence from F2 as starting point e.g. 1007, the actual starting point will be the corresponding sentence in F3: 2007. This is because the book F3 occupies the slot 2 which should actually be covered by F2. Similarly, if I select a sentence from F3, the actual starting point will be the corresponding sentence in F1, since F1 occupies slot 3 which should be covered by F3 and so on.

The app crashes, when I select a sentence from a book whose slot is not covered at all. E.g. if I only add one book, F2, and want to select a starting point, the actual slot 2 is not occupied by any book and the app will crash.

flackbash commented 5 years ago

Resetting the current session when selecting a starting point is great btw.

chickendude commented 1 year ago

I'm thinking this should be fixed now.