[Web Graphics] Two failures with one simple PyROOT plotter
Check duplicate issues.
- [X] Checked for duplicates
Description
On macOS, it is possible to demonstrate two bugs of the WebGraphics with one simple PyROOT script:
- A crash, upon first execution
- A system freeze, once the browser is loaded
Crash
Upon first execution, a browser window is loaded, however the script exits, even if the input function should stop execution. The error message:
[70538:42503:0510/092746.969274:ERROR:trust_store_mac.cc(750)] Error parsing certificate:
ERROR: Failed parsing extensions
[70538:259:0510/092747.479455:ERROR:background_contents_service.cc(441)] No extension found for BackgroundContents - id = ejidjjhkpiekdjhfgtyshbnagldlkglhimk
$
-> Created TensorFlow Lite XNNPACK delegate for CPU.
The last line is not a mistake: it really appears on my terminal.
Faulty behaviour: Freeze
Now that chrome is loaded, if I re-launch the same script, everything stop before quitting as expected, the webcanvas window is displayed, however it's not responsive: whatever is clicked has no effect.
Reproducer
import ROOT
ROOT.gROOT.SetWebDisplay()
c = ROOT.TCanvas()
h = ROOT.TH1D("","",64, -4,4)
h.FillRandom("gaus")
h.Draw()
input("Press Enter to exit")
ROOT version
6.32 and master
Installation method
Sources
Operating system
MacOS 14
Additional context
No response
How you start python - with or without -i flag?
Graphics (normal or web) can normally works only in interactive python mode.
In such case canvas will be updated while input() is waiting for key.
In none-interactive mode events processing does not work.
I create separate issue https://github.com/root-project/root/issues/15498 concerning gPad in this script.
For me python creates second canvas - without real need.
Thanks. I do not understand. I proposed a simple reproducer that illustrates a bad user experience, very bad, that makes the system unusable. What is the strategy to fix this bug?
Again, workaround with calling input() function in python does not work - neither with web not with normal ROOT graphics. Only when enabling interactive python mode python - i one gets ROOT events processing working.
This problem well known and I discussed it some time ago with @vepadulano.
To make it working one need to provide special TCanvas method which only can be used in python and which properly handle ROOT events processing. Like show method in mathplotlib. Naively TCanvas::Show() can look like:
def TCanvas_Show(self) :
# really display canvas
self._OriginalDraw()
// process event until key pressed or Ctrl-C pressed
while (not_key_press() and not_ctrl_c_pressed()):
gROOT.ProcessEvents()
Most probably it can be introduced in _pythonization/_drawables.py.
But I am not an python/PyROOT expert and have no idea how it can be properly programmed - including keyboard/signals handling.