PDLPorters / PDL-Graphics-Prima

A graphing widget using the Prima toolkit
13 stars 6 forks source link

`demo prima` gives unexpected Ctrl-C message and error at end #51

Open mohawk2 opened 1 year ago

mohawk2 commented 1 year ago

@dk Do you have any idea what causes this? Latest PDL, in perldl:

pdl> demo prima
---- Code:
  # starting up the Prima GUI demo app
  PDL::Demos::Prima::run();
---- Output:
Use of uninitialized value $posn in numeric eq (==) at (LIB)/PDL/Demos/Prima.pm line 311, <DATA> line 224.
----

The "uninitialized value" is if I click "Next" on the last page, after which it changes to a "Finish" button. On clicking "Finish", I see:

pdl> Unknown error: time to exit the event loop at (LIB)/PDL/Demos/Prima.pm line 139, <DATA> line 224.
    ...propagated at (LIB)PDL/Graphics/Prima/ReadLine.pm line 65, <DATA> line 224.

 exiting...
[then it shows the "demo" output again without the "prima" entry, then immediately:]
Ctrl-C detected
Compilation failed in require at (LIB)/PDL/Graphics/Prima.pm line 26.
BEGIN failed--compilation aborted at (LIB)/PDL/Graphics/Prima.pm line 26.
Compilation failed in require at (LIB)/PDL/Demos/Prima.pm line 5.
BEGIN failed--compilation aborted at (LIB)/PDL/Demos/Prima.pm line 5.
Compilation failed in require

To avoid doubt, I didn't press Ctrl-C.

dk commented 1 year ago

Yes, looks like this was always there. This should fix it patch.txt

mohawk2 commented 1 year ago

Thanks! Could you PR it?

mohawk2 commented 1 year ago

Thanks! More strangeness:

pdl> p $$
366399
pdl> demo
Use:
[snip]
   demo pgplotOO    # PGPLOT OO interface
   demo prima       # Prima graphics
   demo transform   # Coordinate transformations (Req.: PGPLOT)
pdl> p $$
366399
pdl> q
Use:
[snip]
   demo pgplotOO    # PGPLOT OO interface
   demo transform   # Coordinate transformations (Req.: PGPLOT)
Ctrl-C detected
 at blib/script/perldl line 228.
    main::__ANON__[blib/script/perldl:229]("INT") called at (LIB)/x86_64-linux/Prima.pm line 59
    eval {...} called at (LIB)/x86_64-linux/Prima.pm line 59
    require Prima.pm called at (LIB)/PDL/Graphics/Prima.pm line 26
[snip]
pdl> p $$
366403

I believe this is because the P:G:Prima demo loads Prima, which initialises itself (at line 59 of Prima.pm), but is then not used. I don't consider it unreasonable for Prima to get itself ready for use on being loaded, and I could make P:G:Prima not load Prima itself, but instead change it so that its using libraries/scripts had to do so (in this case, making the demo do it when run). However, do you think Prima should handle this in a different way? Also I'm not clear why the signal handler (installed by perldl to handle Ctrl-C) is being called at all, and why that seems to fork the process. Might this be due to Prima's END needing to be a bit more careful?

Similar to the above happens when I run the demo and immediately use the window's "X" button to close it, then tell perldl to exit - it reports failing to load the demo, and has a different $$.

dk commented 1 year ago

I'm not sure I understood the protocol, but at my best, I couldn't reproduce:

$ perldl
perlDL shell v1.357
 PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file
 'COPYING' in the PDL distribution. This is free software and you
 are welcome to redistribute it under certain conditions, see
 the same file for details.
ReadLines, NiceSlice, MultiLines  enabled
Reading PDL/default.perldlrc...
Found docs database /usr/local/lib/x86_64-linux-gnu/perl/5.34.0/PDL/pdldoc.db
Type 'help' for online help
Type 'demo' for online demos
Loaded PDL v2.081 (supports bad values)

Note: AutoLoader not enabled ('use PDL::AutoLoader' recommended)

pdl> p $$
1919296
pdl> demo
Use:
   demo pdl         # general demo
   demo bad         # Bad-value demo (Optional: PGPLOT)
   demo cartography # Cartographic projections (Req.: PGPLOT)
   demo prima       # Prima graphics

pdl> p $$
1919296
pdl> demo
Use:
   demo pdl         # general demo
   demo bad         # Bad-value demo (Optional: PGPLOT)
   demo cartography # Cartographic projections (Req.: PGPLOT)
   demo prima       # Prima graphics

pdl> p $$
1919296
pdl> q
$
dk commented 1 year ago

I also have another installation with demos pgplot, pgplot00, and transform - and again, nothing.

I wonder if this could be a mix-up of several module versions in your installation? The string "time to exit the event loop" is only found in the older versions of P:G:P...

mohawk2 commented 1 year ago

With:

On Ubuntu, I am running perldl, with demo and q, and seeing the same spurious "Ctrl-C" and new process.

I see your perldl shows PDL 2.081 (CPAN latest is 2.082). Could you try with these versions? Also, what OS are you on? (Though from that path I assume Linux)

Could you also try installing OpenGL and OpenGL::GLUT? If your demo list is the complete list (mine was cut down), that might have an influence. (Also, the demo 3d is kind of cool, though I am definitely biased!)

dk commented 1 year ago

All right, tried on a fresh ubuntu and perl5.36:

(16:30)dk@hp build/PDL-2.082-0> perldl
perlDL shell v1.357
 PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file
 'COPYING' in the PDL distribution. This is free software and you
 are welcome to redistribute it under certain conditions, see
 the same file for details.
ReadLines, NiceSlice, MultiLines  enabled
Reading PDL/default.perldlrc...
Found docs database /home/dk/perl5/perlbrew/perls/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux/PDL/pdldoc.db
Type 'help' for online help
Type 'demo' for online demos
Loaded PDL v2.082 (supports bad values)

Note: AutoLoader not enabled ('use PDL::AutoLoader' recommended)

pdl> p $$
377867
pdl> demo
Use:
   demo pdl         # general demo
   demo 3d          # 3d demo (requires TriD with OpenGL or Mesa)
   demo 3d2         # 3d demo, part 2. (Somewhat memory-intensive)
   demo 3dgal       # the 3D gallery: make cool images with 3-line scripts
   demo bad         # Bad-value demo (Optional: PGPLOT)
   demo cartography # Cartographic projections (Req.: PGPLOT)
   demo pgplot      # PGPLOT graphics output
   demo pgplotOO    # PGPLOT OO interface
   demo prima       # Prima graphics
   demo transform   # Coordinate transformations (Req.: PGPLOT)

pdl> p $$
377867
pdl> demo
Use:
   demo pdl         # general demo
   demo 3d          # 3d demo (requires TriD with OpenGL or Mesa)
   demo 3d2         # 3d demo, part 2. (Somewhat memory-intensive)
   demo 3dgal       # the 3D gallery: make cool images with 3-line scripts
   demo bad         # Bad-value demo (Optional: PGPLOT)
   demo cartography # Cartographic projections (Req.: PGPLOT)
   demo pgplot      # PGPLOT graphics output
   demo pgplotOO    # PGPLOT OO interface
   demo prima       # Prima graphics
   demo transform   # Coordinate transformations (Req.: PGPLOT)

pdl> 
pdl> q
dk@hp build/PDL-2.082-0> 
mohawk2 commented 1 year ago

Thank you. I shall have to dig into this and see what is going on locally!

dk commented 1 year ago

Just in case, I ran this on the latest Prima snapshot from github

mohawk2 commented 5 months ago

This is something I forgot I'd reported here, and just created https://github.com/dk/Prima/issues/114