phetsims / energy-forms-and-changes

"Energy Forms And Changes" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
5 stars 5 forks source link

Energy chunks from air to burner fall in straight line #156

Closed chrisklus closed 5 years ago

chrisklus commented 5 years ago

When the burners are cooling without blocks or burners on them, the chunks they get from the air fall a straight line instead of the usual wander that thermal chunks have.

kapture 2019-01-11 at 17 44 13

jbphet commented 5 years ago

Should be fixed, assigning to @chrisklus to review and test.

chrisklus commented 5 years ago

Unfortunately, I was able get one of the burners to ignore what is sitting on it. I've been trying to reproduce consistently for a while and am not yet sure what the base condition is. So far, I've been able to reproduce three times in about half an hour, and it always has involved a triple stack being heated for a while on fast forward with heaters linked, and then switching to cooling, and both burners start to get chunks from the air. It seems like as the stack is being heated, each element starts to ignore the incoming chunks and they're lost to the air instead, starting with the beaker on top and moving down the stack.

kapture 2019-01-14 at 20 33 05

kapture 2019-01-14 at 20 35 28

Also, there's some weirdness with energy chunks returning to a block. I've only been able to get to this state after the bug above is in effect. However, once the above bug does happen, everything goes pretty wild, not just the effects seen below. Once, a stack of elements disappeared just from clicking it, and then they reappeared on the other side of the sim a few seconds later.

kapture 2019-01-14 at 20 41 23

jbphet commented 5 years ago

The odd behavior seems to have been an issue with vector pooling. In an attempt to reduce allocations, and thus improve performance, the energy chunk wander controllers were trying to create their position vectors from a pool. For some reason, this was resulting in vector values getting overwritten, which means some of the things they were getting from or releasing to the pool weren't actually unused by other code. I've removed all of the pooling from EnergyChunkWanderController, and the problem appears to have gone away.

chrisklus commented 5 years ago

Since the title part of this issue have been fixed, and the latter part of this issue is redescribed in #172, I'm going to close this and leave any remaining work for #172.