Bug fix: prevent KCL error due to colliding AST execution on project switch (#3205)

* Only run "Execute AST" action if defaultUnit setting changes

* A little more logging and catching anywhere we call video.play()
This commit is contained in:
Frank Noirot
2024-08-01 01:40:14 -04:00
committed by GitHub
parent 41b1ec94fa
commit 1ac39d95f2
5 changed files with 55 additions and 10 deletions

View File

@ -156,7 +156,10 @@ export const Stream = () => {
useEffect(() => {
setIsFirstRender(kclManager.isFirstRender)
if (!kclManager.isFirstRender) videoRef.current?.play()
if (!kclManager.isFirstRender)
videoRef.current?.play().catch((e) => {
console.warn('Video playing was prevented', e)
})
setIsFreezeFrame(!kclManager.isFirstRender)
}, [kclManager.isFirstRender])
@ -170,8 +173,12 @@ export const Stream = () => {
if (!mediaStream) return
// Do not immediately play the stream!
videoRef.current.srcObject = mediaStream
videoRef.current.pause()
try {
videoRef.current.srcObject = mediaStream
videoRef.current.pause()
} catch (e) {
console.warn('Attempted to pause stream while play was still loading', e)
}
send({
type: 'Set context',