Open ghost opened 5 years ago
This is a known problem from https://github.com/phetsims/wave-interference/issues/331, but surprising that it only occurred in Wave Interference and not Waves Intro. I'll take a look.
Also, I wonder about the performance improvements @pixelzoom and @jonathanolson discussed for Gas Properties. If we can eliminate the requirement to use WebGL on iOS without sacrificing performance, we can address the clipping problem.
In the preceding commit, I made it so Waves Intro uses WebGL on mobile safari to improve performance, as we decided for Wave Interference. Good catch @lmulhall-phet! I'll move the preceding comment to #331.
@samreid Before investigating WebGL, you might consider making some straightforward optimizations to your for
loops. I see many for
loops where the exit condition is being reevaluated on every iteration. These types of optimizations resulted in a significant performance improvement (+5fps) for Gas Properties, see https://github.com/phetsims/gas-properties/issues/146#issuecomment-515237667.
First, if your array is large, rather than using i < array.length
as your exit condition, iterate in reverse. For example in IntensityGraphPanel.js:
- for ( let i = 0; i < intensityValues.length; i++ ) {
+ for ( let i = intensityValues.length - 1; i >= 0; i-- ) {
Second, if your exit condition is a constant, factor it out, do not put it in the for
expression. E.g. in Lattice.js:
- for ( let i = 0; i < this.width - this.dampX * 2; i++ ) {
+ const iMax = this.width - this.dampX * 2;
+ for ( let i = 0; i < iMax; i++ ) {
I measured the profiler frame rate with throttle x4, then replaced all of the for let
end conditions with constants and re-ran the profiler. There was not a significant difference in the frame rate for this simulation. I'll leave the code as it is for now.
UPDATE: To clarify, I tested both water waves (38fps) and sound particles (24fps) in requirejs mode.
In #322 we got good performance on the particles via WebGL, but did not add clipping due to the amount of time and complexity it would take to implement. This problem is noted in #331. @arouinfar or @ariel-phet do you want to work on that further before we publish?
@samreid this is really a question of priorities and desired publication timeline. I believe the goal was to have these sims published in time for the next school year (which has already started in some parts of the country). I am fine with continuing to defer the clipping issue, but @ariel-phet should make that call.
I am fine with deferring. @samreid perhaps keep this task in mind for an intern.
Deferring sounds great. Some notes for when we revisit this issue:
ImageWebGLDrawable
or thereabouts. It should be implemented in a way that is compatible with broader scenery clipping for the future. It would be good to get assistance or guidance from @jonathanolson.
Test Device
Hopper
Operating System
iOS 12.4
Browser
Safari
Problem Description
For https://github.com/phetsims/QA/issues/389. I've only seen this in Wave Interference, not in Waves Intro. See the title and visuals. This bug is present in the published version.
Steps to Reproduce
Visuals