[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shr using `make-xwidget' incorrectly

From: Po Lu
Subject: shr using `make-xwidget' incorrectly
Date: Thu, 11 Nov 2021 09:54:51 +0800

Lars, you might want to know that `make-xwidget', invoked without a
buffer argument, will create an xwidget attached to the current buffer.

That xwidget won't be killed until you kill the buffer it's attached to.
So you should either try to re-use existing xwidgets (see
`get-buffer-xwidgets'), or to kill the buffer the xwidget is attached
to.  Otherwise, every re-render will cause more xwidgets to be created,
leading to undesirable resource consumption (WebKit widgets are heavy!).

Which reminds me of another problem (in the Emacs 28 xwidget code as
well): If an xwidget's buffer is killed, but references to it still
exist somewhere, crashes can happen, because the GTK resources allocated
to the xwidget are killed in `kill_buffer_xwidgets' and not during
garbage collection.

I think the best thing to do in this case would be to introduce a
`dead' state for xwidgets, not unlike killed buffers and dead frames,
which an xwidget is set to after being killed.

Then, performing any sort of operation on a killed xwidget can either
throw an error, or do nothing.

But I'd like the others to chime in as well.  Thanks.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]