collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
869 stars 99 forks source link

Casting spells too fast on Android causes crash #113

Open collinsmith opened 3 years ago

collinsmith commented 3 years ago

Casting spells too fast on Android causes crash. I think that android I/O is too slow which is causing a crash if too many spells are casted in succession. Requires more investigation, because there should be an I/O block until the asset is loaded, but the app is pushing on ahead and getting an IOOBE.

collinsmith commented 3 years ago

I'm seeing similar crashes on desktop now that I've implemented basic combat. I worked around the issue by returning valid values from the problematic function calls, but these should be reverted when this issue is resolved.

I believe this issue is related to having a dynamic number of directions based on animation. Changing animations should copy the current directions, so it looks like this is happening for invalid directions (who should default to closest direction, or 0). After solving the issue in this comment, I need to double check the original issue on android to see if it was the same problem.

collinsmith commented 3 years ago

Yea... after looking into it a bit more, I'm pretty confident this is the issue. Far less apparent on desktop due to I/O speeds being way faster. Due to how animation layers are streamed, some layers may not have the same number of directions (or frames) as needed at the time of drawing. This can be fixed in a few ways, potentially the easiest would be to simply clear the old layers when the cof changes, but what I want to try also is using bit flags to know when required layers are loaded.

I/O speedups could also alleviate this issue. I'm sure I will probably want to cache certain animations later (especially on android), but that is an optimization that I am leaving for another time when I have a better understanding of what assets are required.

6 small changes work around this issue for now to hide it.

collinsmith commented 3 years ago

I noticed at least one specific bug which may be causing this issue with the quillrat missiles not moving. I'll look into that, since they should be. Resolved by below commit. Waiting to see how issue progresses.