Skip to content

Commit a24fa47

Browse files
committed
Improve CPU usage to 1~3% when is not playing
1 parent 386d5b4 commit a24fa47

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/components/audio/component.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Audio extends Component {
8787
canvasCx: null,
8888
canvasCy: null,
8989
canvasCoord: null,
90+
firstDraw: true,
9091

9192
/**
9293
* Framer Context
@@ -744,9 +745,17 @@ class Audio extends Component {
744745
}
745746

746747
sceneRender() {
747-
requestAnimationFrame(() => {
748+
if (this.state.firstDraw) {
748749
this.sceneClear()
749750
this.sceneDraw()
751+
this.setState({ firstDraw: false })
752+
}
753+
754+
requestAnimationFrame(() => {
755+
if (this.state.playing) {
756+
this.sceneClear()
757+
this.sceneDraw()
758+
}
750759
if (this.state.sceneInProcess) {
751760
this.sceneRender()
752761
}

0 commit comments

Comments
 (0)