You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to capture an image of a pythreejs renderer using ImageRecorder. This works reliably on Chrome, but on Safari it is extremely unreliable. I seem to be hitting some weird race condition, but I do not understand the asynchronous Javascript code involved well enough to figure what is going wrong.
Here is an example demonstrating the problem:
frompythreejsimport*ball=Mesh(geometry=SphereGeometry(),
material=MeshLambertMaterial(color='red'))
light=DirectionalLight(color='white', position=[3, 5, 1])
c=PerspectiveCamera(position=[0, 5, 5], children=[light])
scene=Scene(children=[ball, c])
renderer=Renderer(camera=c, scene=scene, controls=[OrbitControls(controlling=c)])
display(renderer)
#-----------------------------------------------importipywebrtcstream=ipywebrtc.WidgetStream(widget=renderer, max_fps=30)
rec=ipywebrtc.ImageRecorder(filename='capture', format='png', stream=stream)
rec.autosave=True#-----------------------------------------------rec.recording=True#-----------------------------------------------rec.recording# Usually still prints `True` :(
(Comments delimit notebook cells.)
I expect rec.recording = True to (a) rerender the scene, (b) capture and save an image, and (c) reset rec.recording to False. This all happens reliably on Chrome, but (b) and (c) almost always fail on Safari (no image is written, and rec.recording is still True at the end). Manually triggering a second redraw (e.g., by orbiting the view) usually causes (b) and (c) to finally happen.
As best I can tell, ImageRecorder's snapshot function hangs on the onCanPlay call. It appears the redraw requested by pythreejs here is somehow happening "too soon," but I don't understand what order everything needs to happen in.
This is tricky to debug since the capture starts working more (but not 100%) reliably when I insert breakpoints, e.g. here and here.
Do you have any ideas what might be wrong or suggestions on how to debug this? I can also submit an ipywebrtc issue, but I suspect the problem lies in pythreejs' captureStream code.
The text was updated successfully, but these errors were encountered:
I'm not sure if I am able to help here (no access to Safari). Note that even if the issue is with pythreejs' code, making an issue on the ipywebrtc repo might be helpful (maybe they already know, or are able to more accurately debug the issue).
I am trying to capture an image of a pythreejs renderer using
ImageRecorder
. This works reliably on Chrome, but on Safari it is extremely unreliable. I seem to be hitting some weird race condition, but I do not understand the asynchronous Javascript code involved well enough to figure what is going wrong.Here is an example demonstrating the problem:
(Comments delimit notebook cells.)
I expect
rec.recording = True
to (a) rerender the scene, (b) capture and save an image, and (c) resetrec.recording
toFalse
. This all happens reliably on Chrome, but (b) and (c) almost always fail on Safari (no image is written, andrec.recording
is stillTrue
at the end). Manually triggering a second redraw (e.g., by orbiting the view) usually causes (b) and (c) to finally happen.As best I can tell,
ImageRecorder
'ssnapshot
function hangs on theonCanPlay
call. It appears the redraw requested by pythreejs here is somehow happening "too soon," but I don't understand what order everything needs to happen in.This is tricky to debug since the capture starts working more (but not 100%) reliably when I insert breakpoints, e.g. here and here.
Do you have any ideas what might be wrong or suggestions on how to debug this? I can also submit an
ipywebrtc
issue, but I suspect the problem lies in pythreejs'captureStream
code.The text was updated successfully, but these errors were encountered: