root icon indicating copy to clipboard operation
root copied to clipboard

Webgraphics: different behaviour wrt classic graphics with 2 canvases

Open dpiparo opened this issue 1 year ago • 5 comments

Check duplicate issues.

  • [ ] Checked for duplicates

Description

There is a difference in the behaviour of the 2 graphics backends, when drawing on 2 canvases an updated historgam.

Reproducer

TCanvas c1;
TH1F h("h","h", 64, -4,4);
h.FillRandom("gaus");
h.Draw();
TCanvas c2;
h.FillRandom("gaus",10000);
h.Draw();

Classic graphics: One histo with 5k entries and one with 15k entries Web graphics: Two histos with 15k entries

ROOT version

master

Installation method

sources

Operating system

MacOS

Additional context

No response

dpiparo avatar Apr 26 '24 11:04 dpiparo

It is time glitch between web canvas and normal canvas. Web canvas requires some time to be started - and during this time one get histogram fill to the end. If one do c1.SaveAs("c1.png") and c2.SaveAs("c2.png") one get expected values.

linev avatar Apr 26 '24 12:04 linev

Thanks. Nevertheless the problem is there also if commands are run interactively, waiting seconds after the first canvas is drawn.

dpiparo avatar Apr 27 '24 18:04 dpiparo

Problem is extra gPad->Modified() call when new TCanvas is created.

In the macro it marks first canvas always as modified. And at the end of macro execution both canvas are updated to latest histogram content. I create PR #15518 which fixes such bogus behavior. After PR merged one can do:

TCanvas c1;
TH1F h("h","h", 64, -4,4);
h.FillRandom("gaus");
h.Draw();
c1.Update(); // ensures histogram displayed as exists at this point
TCanvas c2;
h.FillRandom("gaus",10000);
h.Draw();

linev avatar May 15 '24 12:05 linev

I do not understand what is going on. Both code snippets with the tip of the master show two identical histograms with 15k entries. The changes had no effect in either case it seems.

dpiparo avatar May 20 '24 09:05 dpiparo

I checked again. With the master branch last macro produces two canvases - with 5000 and 15000 entries.

With the 6.32 ROOT code one have to add gPad = nullptr; before creating second canvas.

linev avatar May 21 '24 07:05 linev

With current master both canvases show 15000 entries for histogram. Looks like after recent changes in ROOT canvases are modified at the end of macro execution. Same behavior seen in master and 6.32 branch in normal and web graphics

linev avatar Jun 05 '24 09:06 linev