Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plots: Dynamic plots not removed when language runtime shuts down #584

Closed
jmcphers opened this issue May 16, 2023 · 4 comments
Closed

plots: Dynamic plots not removed when language runtime shuts down #584

jmcphers opened this issue May 16, 2023 · 4 comments
Milestone

Comments

@jmcphers
Copy link
Collaborator

To reproduce:

  1. Start R and open the Plots pane
  2. Create a plot with e.g. plot(runif(1000))
  3. Exit R, with either q() or with the Shutdown Language Runtime command

The Plots pane still shows the plot.

image

The plot shouldn't be visible any more, since its backend has been removed (comm closed). If you try to resize the Plots pane you'll see it try to redraw but get stuck because the backend is disconnected (note heavy blue line in screenshot).

@jmcphers jmcphers added this to the Internal Preview milestone May 16, 2023
@jmcphers
Copy link
Collaborator Author

Thinking about this a little more ... I'm not sure that aggressively removing the plots from the pane is the correct behavior. We can't resize them any more, but we could still show the last rendered image without much trouble.

@jmcphers
Copy link
Collaborator Author

This is almost certainly related to the error @DavisVaughan noted in another issue, in which we try to disconnect the comm after the kernel has already shut down.

ANSIOutput: Processing Output: "onDidChangeRuntimeState (idle)"
ansiOutput.ts:220
ANSIOutput: Processing Output: "onDidChangeRuntimeState (exiting)"
ansiOutput.ts:220
ANSIOutput: Processing Output: "onDidChangeRuntimeState (exited)"
ansiOutput.ts:220
ANSIOutput: Processing Output: "R: /Library/Frameworks/R.framework/Resources 4.2.2 has exited."
ansiOutput.ts:220
  ERR Cannot read properties of null (reading 'title'): TypeError: Cannot read properties of null (reading 'title')
	at JupyterKernel.sendToSocket (/Users/davis/Desktop/programming/positron/positron/extensions/jupyter-adapter/out/JupyterKernel.js:695:57)
	at JupyterKernel.send (/Users/davis/Desktop/programming/positron/positron/extensions/jupyter-adapter/out/JupyterKernel.js:676:21)
	at JupyterKernel.closeComm (/Users/davis/Desktop/programming/positron/positron/extensions/jupyter-adapter/out/JupyterKernel.js:439:14)
	at LanguageRuntimeAdapter.removeClient (/Users/davis/Desktop/programming/positron/positron/extensions/jupyter-adapter/out/LanguageRuntimeAdapter.js:251:26)
	at ExtHostLanguageRuntime.$removeClient (/Users/davis/Desktop/programming/positron/positron/out/vs/workbench/api/common/positron/extHostLanguageRuntime.js:74:36)
	at RPCProtocol._doInvokeHandler (/Users/davis/Desktop/programming/positron/positron/out/vs/workbench/services/extensions/common/rpcProtocol.js:381:27)
	at RPCProtocol._invokeHandler (/Users/davis/Desktop/programming/positron/positron/out/vs/workbench/services/extensions/common/rpcProtocol.js:366:45)
	at RPCProtocol._receiveRequest (/Users/davis/Desktop/programming/positron/positron/out/vs/workbench/services/extensions/common/rpcProtocol.js:307:32)
	at RPCProtocol._receiveOneMessage (/Users/davis/Desktop/programming/positron/positron/out/vs/workbench/services/extensions/common/rpcProtocol.js:234:26)
	at /Users/davis/Desktop/programming/positron/positron/out/vs/workbench/services/extensions/common/rpcProtocol.js:115:52
	at Listener.invoke (/Users/davis/Desktop/programming/positron/positron/out/vs/base/common/event.js:660:27)
	at PrivateEventDeliveryQueue.deliver (/Users/davis/Desktop/programming/positron/positron/out/vs/base/common/event.js:836:38)
	at Emitter.fire (/Users/davis/Desktop/programming/positron/positron/out/vs/base/common/event.js:800:37)
	at BufferedEmitter.fire (/Users/davis/Desktop/programming/positron/positron/out/vs/base/parts/ipc/common/ipc.net.js:504:35)
	at /Users/davis/Desktop/programming/positron/positron/out/vs/workbench/api/node/extensionHostProcess.js:180:41
	at Listener.invoke (/Users/davis/Desktop/programming/positron/positron/out/vs/base/common/event.js:660:27)
	at PrivateEventDeliveryQueue.deliver (/Users/davis/Desktop/programming/positron/positron/out/vs/base/common/event.js:836:38)
	at Emitter.fire (/Users/davis/Desktop/programming/positron/positron/out/vs/base/common/event.js:800:37)
	at BufferedEmitter.fire (/Users/davis/Desktop/programming/positron/positron/out/vs/base/parts/ipc/common/ipc.net.js:504:35)
	at MessagePortMain.<anonymous> (/Users/davis/Desktop/programming/positron/positron/out/vs/workbench/api/node/extensionHostProcess.js:77:57)
	at MessagePortMain.emit (node:events:513:28)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)
	at Object.callbackTrampoline (node:internal/async_hooks:130:17)

@jmcphers
Copy link
Collaborator Author

I'm not sure that aggressively removing the plots from the pane is the correct behavior. We can't resize them any more, but we could still show the last rendered image without much trouble.

I thought about this a little more and decided that it is the correct behavior, at least for now. It would be easy to show the last rendered image, but there's no place for us to actually store that image today. Consequently, the image would vanish if you reloaded the browser.

It is admittedly a little aggressive to remove the image from the pane right away, but I think that users could understand losing plots when they take a destructive action (shutdown, restart) more than they could losing plots on a UI reload, which should never cause you to lose data.

We will eventually need some storage for the Plots pane for thumbnails if nothing else (see #397), but until we have that set up, I think removal is what we want so that the state remains consistent.

@jmcphers
Copy link
Collaborator Author

This now works in my testing.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant