phetsims / neuron

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

Performance optimization may be required to run well on iPads #55

Closed samreid closed 8 years ago

samreid commented 9 years ago

@jbphet said:

I just tested the fallback for WebGL to Canvas on my iPad 2 for Neuron, and results aren’t good, and we’ll need to decide where to go from here. As a data point, when you have a chance, could you try ?profiler on the current master version of Neuron and let me know what frame rate you see?

BTW, I know you’ve upgraded your iPad 3 to iOS 8 – I just want to see what the performance is like in that environment.

Actually, best would be to do both without the flag (i.e. using WebGL) and with the flag (thus using canvas).

samreid commented 9 years ago

iPad3/iOS8.1.1

RESTING (BEFORE INTERACTION) Webgl: 60fps canvas: 20fps

DURING STIMULATE NEURON: WebGL: 20fps canvas: 11fps

Please let me know if you would like further testing.

jbphet commented 9 years ago

For reference, I tried this on the iPad 2 that I have, which has been intentionally not upgraded to iOS 8, and is currently running iOS 7.0.4, and therefore does not have WebGL available. Results were:

Resting, zoomed all the way out: Canvas: ~27fps

During stimulation, zoomed all the way out: Canvas: ~15fps

I suspect that most people use this fairly zoomed in, since otherwise it's hard to see the details, so here are a couple of tests in that mode:

Resting, zoomed in about 2/3 of the way: Canvas: ~38fps

Stimulated, zoomed in about 2/3 of the way: Canvas: ~20fps

jbphet commented 9 years ago

I just thought I'd add a subjective comment about using this on the un-upgraded iPad 2. In my opinion, it did seem a bit slow, but was not unusable. We should probably review this in the next design meeting and see if people feel that the performance is or isn't acceptable.

jbphet commented 9 years ago

Testing on an iPad 2 that is upgraded to iOS8 and thus has WebGL available:

Resting, zoomed all the way out: WebGL: ~59fps

During stimulation, zoomed all the way out: WebGL: ~23fps

I suspect that most people use this fairly zoomed in, since otherwise it's hard to see the details, so here are a couple of tests in that mode:

Resting, zoomed in about 2/3 of the way: WebGL: 60fps

Stimulated, zoomed in about 2/3 of the way: WebGL: ~27fps

Subjective notes: Slows down noticeably when a stimulation is in progress. Not unusable, but not great.

jbphet commented 9 years ago

Due to work on #65, Neuron is now working with Scenery 0.2 and WebGL. I've published the first working version with these combinations so that we can quantify performance and use it as a baseline against which to measure the efficacy of optimizations. This version can be found at http://www.colorado.edu/physics/phet/dev/html/neuron/1.0.0-dev.11/neuron_en.html.

Performance numbers below were measured using the "profiler" query parameter and looking at the frame rate for 10 successive samples and averaging the result. In some cases, the lowest value seen was also recorded.

On an iPad 2 (model A1395) running iOS 8.3, the performance is as follows:

On iPad 3 model A1416 (Disessa) running iOS 8.3 (12F69)

neuron-zoomed

jbphet commented 9 years ago

I've implemented an optimization in the WebGL particle node where the intermediate particle data is allocated once at sim initialization and updated, rather than reallocated, on each repaint. I ran four trials before and after this change, and the percentage of time spent idle increased 1.52%. It's not a lot, but every little bit helps. Link to commit: cad55ed2ac2374ad6a3520fda7847ab142828c91

jbphet commented 9 years ago

I implemented a change where the EventTimer used by NeuronClockModelAdapter is not clocked by the dt amount and not a fixed amount. It seems to me that this is the way it should have been done initially, else long dt values could lead to slow performance of the sim (which is exactly what was being seen). This change makes iPad behavior way better. Strictly speaking, this isn't really an optimization, it's more of a fix, so I didn't mention this issue in the commit message. For future reference, this is the commit: 3dae114c32da471afee78565ec1c8374fb9ce56f.

jbphet commented 9 years ago

I demoed version 1.0.0-dev.12 (http://www.colorado.edu/physics/phet/dev/html/neuron/1.0.0-dev.12/) on an iPad 3 at today's status meeting. @ariel-phet said that the performance of particle motion is adequate. I'm still going to try a couple more optimizations that I think will help, but then will move on to speeding up the zoom in/out.

jbphet commented 8 years ago

Assigning to @ariel-phet so that he or someone on the QA team can verify that performance is acceptable on v1.0.0-rc.2 (http://www.colorado.edu/physics/phet/dev/html/neuron/1.0.0-rc.2/neuron_en.html).

ariel-phet commented 8 years ago

Zooming is very smooth.

I would not classify performance as the "buttery smooth" level on iPad2 for stimulating the neuron, however, any stutters are generally minor enough to not raise fear of causing any pedagogical difficulties. I think most people will not even notice. Performance deemed acceptable. Closing