bbc / VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
http://bbc.github.io/VideoContext/
Apache License 2.0
1.33k stars 157 forks source link

Minor tweaks for performance optimization #132

Closed munwaikong closed 5 years ago

munwaikong commented 5 years ago

This PR contains a couple of renaming typos and variables as well as 2 minor tweaks for performance improvements:

1) Reduce the number of calls to gl.getUniformLocation() as per recommendation of mdn

2) Reduce the number of calls to clearTexture every RAF if the state is the same as before.

PTaylour commented 5 years ago

@munwaikong fantastic, thank you. I'll review today.

munwaikong commented 5 years ago

In terms of benchmarking, what I did was comparing the CPU, frames per second and timings reported in Chrome Dev Tools Performance tab.

Find some screenshots below:

Snapshot of original performance (without changes applied)

m

Snapshot of performance with changes applied

2

If you flip between the 2 images, you can see a lower CPU usage and the script times are slightly lower as well.

PTaylour commented 5 years ago

Awesome, thanks for sharing those :)