phetsims / curve-fitting

"Curve Fitting" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 3 forks source link

Sim does not open on iPad #123

Closed SaurabhTotey closed 5 years ago

SaurabhTotey commented 5 years ago

@veillette and I were talking through a few issues yesterday, but we ran into another new issue. Apparently, when trying to open the simulation on an iPad to test another issue, we found that the simulation would get stuck in loading, almost halfway. This behaviour seems to resemble what it would look like if a simulation errored. We tried running grunt build and then running the build version, but even that version still got stuck. In order to make sure that this wasn't an issue with the iPad, we ran a bunch of other sims which seemed to load and run just fine. I am currently unable to get my hands on a cable to connect the iPad to my mac at this current moment, so I will look further into this later.

SaurabhTotey commented 5 years ago

After trying to run dev versions of this simulation, I have found that the 1.0.0-dev.7 version runs on the iPad, but the new 1.0.0-dev.8 version that I made doesn't run. This probably means that recent changes from me must be behind what is breaking this simulation on iPad.

SaurabhTotey commented 5 years ago

After testing running the sim on the iPad during different points within the commit history, I have been able to narrow down that the first commit where the simulation breaks on the iPad is 95087852de856805e505429e1bce4319a0a6ee13. I will need to look further into why this commit is breaking the simulation on iPad.

SaurabhTotey commented 5 years ago

I have now figured out and solved this issue. I will document my process and the issue here just for future reference. I was looking through 9508785 and I couldn't find any reason for why that code would break on the iPad. After a while of searching, I found an inconspicuous .flat() call. I decided that flattening arrays was the only thing from that commit that survived. I looked through master, and sure enough, there were calls to flatMap, so I replaced those with .map() and .reduce() to map and flatten the arrays that I was previously flatMaping. That seemed to fix the issue and now the current code on master works on iPad. Regardless, my current solution is much less efficient than a flatMap, so I will probably be reworking the code from my fix to be more efficient, faster, and more readable/documented.

SaurabhTotey commented 5 years ago

Just for more reference, I have since replaced the .map(...).reduce(...) with _.flatMap(...) using lodash to flatMap.