Closed wongjiahau closed 3 years ago
In the end, the New flow is not used, because it is hard to implement, so after the fix, the Old flow is still being used.
I found the actual problem that caused the crash.
App don't crash
Notice some of the red lines point to the top left corner.
After this screen is reached, clicking on any of the slots will crash the app, resulting in whitescreen.
Closed by d9c31f80a023ffeca5872076a918a4e4c5521ff4
Root Cause (this is not entirely correct, need to also read comments below)
This is probably because the algorithm for
findAlternativeSlots
andgoToThisAlternativeSlot
is buggy, due the frequent usage of for loops and array indexing. Not only does this algorithm crash the app sometimes, it is actually incomplete, in the sense that it will not search for all possible destination timetables for each slot.Solution
First of all, we ned to remove for loops and and array indexing (which will incur performance cost). Secondly, the main flow of this feature needs to be changed to minimise the performance impact.
Old flow
When view a new timetable, find all the alternatives slots for each slot of the current timetable. Because of this, showing alternative slots and going alternative slot is almost costless.
New flow
Because the new algorithm utilises only higher order functions like filter, map, reduce, and this algorithm aims to be complete (see above for what incomplete mean). Thus, the new flow is as follows: When view a new timetable, only find out which slots has alternative slots (which means the search loop can stop whenever we find a first alternative timetable), then we will only search for all destination timetables when user want to show the alternative slots of a particular slot.