-
Notifications
You must be signed in to change notification settings - Fork 257
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
Issues with fl_overlay_rect on Linux and Mac #735
Comments
@dannye Thank you for the detailed report and the videos. As you may know, FLTK 1.3 is at its end of life and will only get fixes for major bugs. We are planning to release 1.3.9 soon, very likely as the last 1.3.x release. Many issues have been fixed in 1.4.0, and some of the issues you mention appear very familiar. I'm not going into all details of your report right now, but looking at the FLTK test and demo code, the only place where we're using
That said: please give FLTK 1.4 a try and run
If your program uses coordinates beyond the window borders then this could be called a programming error but I agree that FLTK should not crash. To verify this we really need a short test case (a complete program source code in one file) that shows the issue so we can confirm and fix it. Can you provide such a short program with code similar to what your own program does? Thanks in advance. |
@Albrecht-S So far, I've just tested Here is what I found. On branch: branch-1.3 (not tag release-1.3.8 that I've been using up until now): fltk-1.3-mandelbrot.mp4Not sure why the drawing area gets stale. And on branch master (ie, 1.4): fltk-1.4-mandelbrot.mp4The uneven dotted lines seem to be significantly worse on my system in version 1.4. I will continue to comment here if I test |
Testing on Mac branch-1.3: (has a very strange "smearing" issue) fltk-1.3-mandelbrot-mac.mp4master (ie, 1.4): (works fine) fltk-1.4-mandelbrot-mac.mp4 |
Testing on Windows branch-1.3: (has the egregious delay/flickering) fltk-1.3-mandelbrot-windows.mp4master (ie, 1.4): (seemingly has the same behavior/performance as 1.3): fltk-1.4-mandelbrot-windows.mp4 |
Reproducing the crash on Mac in 1.3 The crash can easily be reproduced in 1.3 using the mandelbrot demo by simply commenting out the two fltk-1.3-fl_overlay_rect-crash-mac.mp4The crash does not happen in 1.4: fltk-1.4-fl_overlay_rect-no-crash-mac.mp4However, you can see in both of these videos that 1.3 and 1.4 on Mac have a weird smearing issue if the rect is partly offscreen (different from the smearing issue I mentioned in my previous comment): You said:
I would disagree that it could be described as a programming error. |
I may be too un-knowledgeable here, but isn't it strange that in the mandelbrot demo Line 219 in 7d7edcf
I could be barking up the wrong tree, but I wonder if some of the issues are due to a malformed demo program rather than a bug with FLTK. |
Thanks for further testing and your videos, and for your comments. I believe that
That's why I used "could". ;-)
Thanks for your opinion, point taken; this should be considered.
Unfortunately the documentation is pretty sparse on how to use |
@dannye Function
That kind of operation is visible in the mandelbrot test program of the FLTK source code. |
An important element here is the statement before the call to This statement directs all future drawing statements to draw to the active Fl_Window. That's the reason why it's possible to use function I don't succeed to reproduce on my MacBook Pro the smear you mention with macOS, FLTK 1.4 and the (modified) mandelbrot test program. Could you describe with more detail how to get it? |
@ManoloFLTK Sure, here's a longer video demonstrating when exactly the smearing does and does not happen: fltk-1.4-mandelbrot-smear-mac.mp4This was from commit If I keep the overlay rectangle within the window, the smearing does not happen. But as soon as the overlay rect is dragged outside the window to the right, the "smearing" appears as horizontal streaks (presumably because the previous overlay rect is not being "erased" correctly). In the second half of the video I show that vertical streaks also appear if dragging the overlay rect below the bottom edge of the window. |
tl;dr: fl_overlay_rect() is very specific in what it does. It's a hack for old slow computers and should probably not be used anymore unless the user know its limitations. If teh devs are ok with it, I will update the docs and leave it at that. Ok, sorry, I completely missed this thread when it was created. I can give a little history, and maybe we can come up with a solution. The original target platform of FLTK, SGI computers, had a hardware overlay plane in X11. Fl_Overlay_Window used that feature, and in draw_overlay(), you could draw anything without the need to call refresh()/draw(). This was important because draw() calls could take much more than the 50th f a second it takes on 2023 machines. We used the overlay plane to visually select nodes in our GUI. When we ported FLTK to MSWindows, there was no longer a hardware overlay, so Fl_Overlay_Window was modified to draw the regular graphics first and then the overlay on top. This takes significantly longer than just redrawing the overly plane. So we came up with a special use case when all we needed in the overlay was a single rectangle, but there was no time to refresh the entire window: we simply XOR a line over the existing drawing to draw the rectangle. fl_draw_overlay() was designed as a quick fix for missing hardware. The intention is to avoid Fl_Overlay_Window and instead draw something that looks like a rectangle while the actual graphics must(!) remain static. The idea was to use FL_PUSH, FL_DRAG, and FL_RELEASE to initiate, draw, and clear the rectangle, while avoiding refresh. The original implementation simply XOR'd a white line over the existing drawing to draw, and XOR'd again to erase the rect. Now, with computers getting faster and users expecting instant refresh, fl_overlay_rect is too limited. The correct solution here is to use Fl_Overlay_Window and implement draw_overlay() using the original drawing functions fl_color(), fl_rect(), etc. . If the content of the window changes, call redraw(), if the overlay changes, call redraw_overlay(. FLTK will take care of the rest. As for the smearing on macOS, that is my fault. Eventually, the XOR drawing method was no longer adequate, so I decided to implement fl_overlay_rect by reading the current screen content into four skinny images and then drawing the dotted line, disturbing the original content. If the rect is moved or erased, the old content is restored by drawing the skinny images where the dotted lines were. This has the same limitations (the original content must no change), but allows for a beautiful dotted line (no clue why X11 doesn't do that correctly). Why does that smear on MacOS? Well, Apple introduced Retina displays, and the original code reads the screen at 100%, but Retina renders at 200%, so reading the screen effectively runs a blur filter over the restored screen content. So dragging the rectangle around a lot will continuously blur the content until it's refreshed the next time. |
That used to be true, but is no longer. Retina displays are now correctly handled by fl_overlay_rect on macOS: 2-pixel wide or high images are read from the screen and drawn back to screen to erase the dotted rectangle. |
@MatthiasWM Thank you for that useful info. I'll be honest, my desire to use I first tried to use I'm aware that custom box type routines can be provided, but I haven't experimented with that yet. |
Try this inside
|
Wow, thanks, that fixes all my problems at once. I should have taken note of I just had to account for negative width and/or height since This also allows me to customize the style and only use |
Nice. I am glad that this works for you ;-) and thanks for the feedback. |
Updated documentation in c5f5973. |
Thanks to Matt for the improved docs, I just fixed some typos and added '()'s for better doxygen comments of functions.
Thanks to @MatthiasWM for the improved documentation. Edit: ... and thank you very much for the "history" comments. This is always good to know. Yet another commit (157d276) fixes some typos and improves doxygen links of function names. |
Thanks. Sorry for the typos. |
Describe the bug
Apologies if this ends up being a bit all over the place.
Note: Putting the videos in fullscreen mode makes the issues much clearer.
tl;dr,
fl_overlay_rect()
's dotted border drawn incorrectly on Linux. Crashes when drawn too far outside the window on Mac.In my application, I changed my
Fl_Double_Window
to aFl_Overlay_Window
so that I could implement adraw_overlay()
in order to draw afl_overlay_rect()
.But there was an unbearable flicker:
overlay-rect-windows-flicker.mp4
I was able to avoid the flicker by abandoning
Fl_Overlay_Window
and sticking with aFl_Double_Window
and simply puttingfl_overlay_rect()
indraw()
instead of indraw_overlay()
(although I may be assuming incorrectly thatfl_overlay_rect()
may be called in any general purposedraw()
).This now works fine on Windows and is much more responsive than
draw_overlay()
:overlay-rect-windows.mp4
However on Linux, the dotted line for the overlay rectangle is often corrupt and uneven, especially on the top border, although all 4 borders may be affected:
overlay-rect-linux.mp4
And on Mac, it crashes if I drag the rectangle a little too far outside the window:
overlay-rect-mac.mp4
To Reproduce
I may try to find time to create a minified repro program that demonstrates the issue. (EDIT: done, check comments)
If you're really interested, the repo where this issue exists is here: https://github.com/dannye/crystal-tracker
Although I don't really expect you to go so far out of your way to build the thing.
Expected behavior
I would expect
Fl_Overlay_Window
/draw_overlay()
/fl_overlay_rect()
to not have terrible flicker/lag (at least on Windows). (Full disclosure, I didn't even testFl_Overlay_Window
anddraw_overlay()
on Linux or Mac.)On Linux, I would expect
fl_overlay_rect()
to not have a corrupt, uneven dotted line.On Mac, I would expect
fl_overlay_rect()
to not crash if used to draw a rect that extends beyond the client rect.Screenshots
See video clips above.
FLTK Version
FLTK Configure / Build Options
Windows:
Added
#define FL_ABI_VERSION 10308
in abi-version.ide.Opened ide\VisualC2010\fltk.sln.
Built the following .lib files: fltk, fltkimages, fltkjpeg, fltkpng, and fltkzlib
Linux and Mac:
Operating System / Platform:
The text was updated successfully, but these errors were encountered: