thetwom / toc2

Metronome app
GNU General Public License v3.0
159 stars 23 forks source link

Version 1.6.0 crashes immediately after launch #6

Closed dkbg closed 4 years ago

dkbg commented 4 years ago

First of all, I really like the interface decisions you've made with this app! Very functional and intuitive.

Version 1.6.0 (installed via F-Droid) crashes immediately after launching. The first attempt appears to initialise the app, then it disappears. Subsequent attempts give the "Metronome keeps stopping" popup.

1.5.1 works fine.

I'm running stock firmware on a Motorola Moto G7 Play.

thetwom commented 4 years ago

Thanks for your report. I am sorry to hear, that the app crashes on your phone. Unfortunately I cannot reproduce the error here which means it is harder to track down. Let me know if you are willing to support me here.

I would especially be interested in the log-messages. You basically get them by enabling the developer options on your phone (Find the build number in "Settings > About Phone > Build Number" and tap on this number seven times, then you find the developer options under "Settings > System > Advanced > Developer Options", and there is the option "Take bug report" which is normally directly at the top). For the "bug report" your would choose the default option. For me I then get a notification, showing some progress bar. If tapping on the notification it asks me some details (none really needed), and when done you can share the result.

But before going into more details here and how to share this file (this shouldn't really be made public), let me know if you are willing to take the efforts. Otherwise I will see when I find some time and if I can spot the bug without more hints. There is also version 1.6.1 coming up, which fixes an issue, but I fear this won't solve your problem.

dkbg commented 4 years ago

So I did some investigating and found some things in the logcat generated by the bug report function. This section (lines 84-103 in the attached file, I started the app twice so there are actually 2 duplicate stack traces in the file) looks particularly important, seems there's an array being indexed with too high a value in the de.moekadu.metronome.AudioEncoderKt.audioToPCM method:

05-11 11:13:09.215 10263 11519 11519 E AndroidRuntime: java.lang.RuntimeException: Unable to create service de.moekadu.metronome.PlayerService: java.lang.ArrayIndexOutOfBoundsException: length=13584; index=13584

See the attached file for the logcat section I was looking at. Let me know if you need more information!

de.moekadu.metronome-crash-debug.txt

thetwom commented 4 years ago

Thanks a lot!!! This is great work. It means that I am allocating not enough memory when decoding the audio files. This is unexpected and I never would have found that without your hints. However, I still have to find out, why audio decoding behaves differently on your phone since.

Would you be willing to install small tests on your phone to get more information? I would upload an apk files, which you simple would have install on your phone.

However, it might take me some days to get it ready ...

dkbg commented 4 years ago

I would be willing to install a test APK, sure.

Seems like you're doing pretty low-level decoding work in the app, isn't there some Android API function to do the work you're doing? Please forgive my ignorance, I only have surface-level knowledge so I probably just don't understand what's being done!

thetwom commented 4 years ago

It's not really low level decoding, it's just using a given decoder and storing the result. Seems pretty simple ;-). I don't know why this results in more sound samples on your phone than on my phone. A silly mistake? A rounding error? Hopefully we will find it soon.

thetwom commented 4 years ago

Ok, here we go: https://github.com/thetwom/DecoderTest/releases/tag/v1.0.0 There you find an apk which loads all the sounds and prints some info to the screen. Would be great if you could post the output (or a screenshot, if not everything fits on the screen, make sure you scrolled up ...). Hopefully, this does not crash. If it does, let me know and I will add more checks ...

thetwom commented 4 years ago

Just in case, you are interested ... this is my output Screenshot_20200512-192529_DecoderTest

dkbg commented 4 years ago

Okay, I've installed it and...unfortunately it crashes immediately on launch! ("DecoderTest keeps stopping" popup when I try to launch again)

dkbg commented 4 years ago

This seems to be the cause:

java.lang.RuntimeException: Unable to start activity ComponentInfo{de.moekadu.decodertest/de.moekadu.decodertest.MainActivity}: java.lang.RuntimeException: AudioEncoder.decode: failed to get input buffer index

thetwom commented 4 years ago

Thank for the quick response. I didn't expect this. I drafted a new version: https://github.com/thetwom/DecoderTest/releases/tag/v2.0 which hopefully should fail anymore.

dkbg commented 4 years ago

Here's my output.

Screenshot_20200512-161551

thetwom commented 4 years ago

perfect, thanks, this explains the reason. The duration given by your output seems to be resolved in milliseconds instead of microseconds. Based on these numbers I do not correctly compute the correct frame number. I guess that the underlying reason is that your phone uses another decoder.

Now, that we know the reason I can easily fix this. Thanks a lot for this investigation. Without your support, I guess, I couldn't have solved this ... . I will upload a new version in the next days.

thetwom commented 4 years ago

Can you try, if this version works for you? https://github.com/thetwom/toc2/releases/tag/v1.6.2-beta

dkbg commented 4 years ago

I've tried the new version, unfortunately it still crashes. It launches, shows a totally blank white screen for several seconds, then quits suddenly.

According to the logcat, this is the exception: java.lang.RuntimeException: Unable to create service de.moekadu.metronome.PlayerService: java.lang.RuntimeException: AudioEncoder.decode: failed to get input buffer index ... Caused by: java.lang.RuntimeException: AudioEncoder.decode: failed to get input buffer index ... AndroidRuntime: at de.moekadu.metronome.AudioDecoderKt.audioToPCM(AudioDecoder.kt:68)

One thing I should also mention is that the debug app does work, but it takes several seconds (probably ~10) for the output text to appear, after initially just showing a blank white screen.

thetwom commented 4 years ago

OK, to bad. It is another problem, though. So thanks again for posting the logcat, this makes the process much easier. The problem that it takes the other app so long and the occuring error message are the same and I hope we can find the reason soon. I would post adapted test when I find some time.

ayysmkz commented 4 years ago

I have the same problem, the app crashes immediately after opening it. I tried the 1.6.2-beta version too, and it has the same problem (although it takes longer before it crashes).

Xiaomi Mi 9T MIUI Global 11.0.5 Android 10

thetwom commented 4 years ago

Hi, thanks for letting me know. Will try to find a solution soon. Situation seems to be pretty clear, so it shouldnt be to difficult to solve the issue :-) May be you can also try the DecoderTest posted above and post the result. This would give me a wider picture...

ayysmkz commented 4 years ago

No problem! Here is the result from the DecoderTest: Screenshot_2020-05-13-17-05-42-005_de moekadu decodertest

thetwom commented 4 years ago

Perfect, thanks.

thetwom commented 4 years ago

Any of you guys could run this new test, report the output and if startup is now faster? https://github.com/thetwom/DecoderTest/releases/tag/v3.0

ayysmkz commented 4 years ago

Now it loads almost immediately Here's the output: Screenshot_2020-05-13-20-03-20-419_de moekadu decodertest

dkbg commented 4 years ago

The new version loads immediately. Here's my output:

Screenshot_20200513-142130

thetwom commented 4 years ago

new try: https://github.com/thetwom/toc2/releases/tag/v1.6.2-beta2

dkbg commented 4 years ago

Great! Looks like the problem is fixed. Everything seems good with this latest version.

thetwom commented 4 years ago

Great to hear. Thanks again for your help investigating.