Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

MediaRecorder Not Capturing Updated Konva Canvas in React

I’m building a simple video creator using react-konva, where I manipulate a Konva canvas and record it using MediaRecorder. One feature I want to implement is simple subtitles—an array of strings displayed sequentially with a 1.5s gap between each (i.e., start recording → switch between all subtitles → stop recording).

I’ve implemented this, and it almost works. However, I keep running into this issue:

  • The recorded video only contains a still background and the first subtitle, resulting in a short (~1s) video.
  • If I manually drag the text around with my mouse during recording, everything is recorded properly.

Reproducing the Issue

I created a CodeSandbox example:

  1. Click Start Recording, wait for the subtitles to change, then download the video.
  2. Try again, but this time move the text with your mouse while recording—the video records correctly!

What I’ve Tried

To force canvas updates to propagate to the MediaStream, I’ve tried:

  • clearCache(), draw(), batchDraw()
  • Firing dragstart, dragmove, dragend events
  • Forcing a slight position change (node.x(node.x() + 1)) after each subtitle update
  • Saving the canvas as an image using toDataURL() after each subtitle update (the correct subtitles are shown on the saved images, but the recording still doesn't have the updated subtitles)

Nothing has worked. I’m not sure why manually dragging the text works but updating it programmatically doesn’t.

Any insights on why this happens or how to ensure all subtitle changes get recorded correctly?

Answer*

Draft saved
Draft discarded
Cancel

lang-js

AltStyle によって変換されたページ (->オリジナル) /