Function fd_callback is associated to the file descriptor over which all communicationbetween the app and the Wayland compositor occurs. This association is established byFl::add_fd(wl_display_get_fd(wl_display), FL_READ, (Fl_FD_Handler)fd_callback, wl_display);in function Fl_Wayland_Screen_Driver::open_display_platform(), that is, when the display is open.Therefore this function is called only when the OS detects that there is something to be readon that file descriptor.Then, function fd_callback also recursively calls itself in a do / while loop,
but the conditionfor the loop to iterate is while (poll(&fds, 1, 0) > 0); which ensures again that there issomething to be read.Therefore, the call to wl_display_dispatch(display) should not block, unless some child threadalso calls functions such as Fl::wait().
On Sat, 24 Dec 2022 at 11:59, Manolo wrote:
>
>> Therefore, the call to wl_display_dispatch(display) should not block, unless some child thread
>> also calls functions such as Fl::wait().
>
> This conclusion remains unchanged.
Nevertheless, As Gonzalo says, there is something weird happening at
times: Whilst testing the Wayland port, but only using the fltk tests
and examples, I have seen scenarios with animation (e.g. the cube or
fractal demos, etc.) get into a "stuck" state where they would only
update whilst I was wiggling the mouse over them.
That said, I have been unable to reproduce this effect today at all,
and TBH I don't actually recall what setup I saw the issues on - I
tested with Weston and with mutter, on my Ubuntu hosts (AMD64 and Pi
ARM64 both) and with the WSL/WSLg setup hosted on Win11 and *today*
they all work. That has not always been the case.
Nevertheless, As Gonzalo says, there is something weird happening at
times:
Yes. Function fd_callback() got its present form relatively recentlyprecisely to avoid blocking situations that occurred at times previously.I believe only the behaviour of test apps as of today is to be considered.
The problem does not seem to be with the fd_callback function
itself, but what happens before that makes wl_display_dispatch
block in my application. Here's some printf's that show what goes
on on my program:
...etc...
=======================================================
Entering fd_callback with fd=3 display=0x2f41120
Call wl_display_dispatch
Called wl_display_dispatch
Called poll returning=0
Returned from fd_callback
=======================================================
Entering fd_callback with fd=3 display=0x2f41120
Call wl_display_dispatch
****BLOCKS****
With current HEAD of fltk1.4, the cube demo stops the animation when you do the following:
* You bring the cube window to the front by clicking on the top
bar of it.
* You click on the terminal window (the one you fired the cube
demo from, for example) to bring it to the front.
The cube starts animating once again after a while or after you
enter the cube window again.
Note, however, this is a different bug than the one I am
referring to.
For my bug, neither the cube or fractal demos are a good example, as they call fd_callback only when there's no redrawing:
- With the cube demo, when speed is 0 and you move the mouse.
- With the fractals demo, when you stop the animation.
Then, function fd_callback also recursively calls itself in a do / while loop,There is an error in that sentence. It should be
Then, function fd_callback calls function wl_display_dispatch() in a do / while loop,
I changed wl_display_dispatch for wl_display_dispatch_pending() and that removed the blocking on that function. Indeed the playback improved. However, I still get some blocking somewhere else (still don't know where).
The documentation for that function mentions I should be calling
wl_display_flush afterwards, too. And it mentions as an example
just my use case: a video player. However, the explanation on how
to use the functions went over my head.
With current HEAD of fltk1.4, the cube demo stops the animation when you do the following:
* You bring the cube window to the front by clicking on the top bar of it.
* You click on the terminal window (the one you fired the cube demo from, for example) to bring it to the front.The cube starts animating once again after a while or after you enter the cube window again.
I changed wl_display_dispatch for wl_display_dispatch_pending() and that removed the blocking on that function. Indeed the playback improved. However, I still get some blocking somewhere else (still don't know where).
Le samedi 24 décembre 2022 à 19:03:15 UTC+1, ggar...@gmail.com a écrit :
I changed wl_display_dispatch for wl_display_dispatch_pending() and that removed the blocking on that function. Indeed the playback improved. However, I still get some blocking somewhere else (still don't know where).
Replacing wl_display_dispatch() by wl_display_dispatch_pending() in a single threaded FLTK appproduces an app that never opens any window. That is to be expected because in that situation
the app will never read data arriving on the Wayland file descriptor.
Fl_Gl_Wayland_Gl_Window_Driver::swap_buffers()
when it calls:
wl_display_read_events(fl_wl_display());
// this stops the event loop for some seconds (or less) and then
continues.
I have detailed previously why a single threaded app cannot block in function fd_callback(). In short, that's becauseall read attempts are done immediately after a call to select/poll that guarantees the presence of data to be read.
I therefore more and more believe that your app makes forbidden calls to functions such as Fl::wait(), Fl::check()or Fl::ready() from a child thread. That's the only explanation I can think of for the blocking you report.
As a test, I commented out the wl_* functions in
Fl_Gl_Wayland_Gl_Window_Driver::swap_buffers() leaving just the
eglSwapBuffer call and left the call to wl_display_dispatch() in
fd_callback as you suggested.
My application then played the video correctly and responded to
my mouse movements, without any stuttering or blocking, as long as
my mouse was in the window of the viewer. When it left the
window, the refresh of my opengl window stopped (but it did not
block, as the video playback continued in the background --it just
was not shown).
This of course is not a solution but just a test as my
application eventually crashed when my mouse left the main window
and entered it again and also the demo programs did not respond to
mouse dragging. But to me, it pointed out an issue with the wl_*
calls.
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/4260547a-e5f7-4e97-9015-04ea5684044en%40googlegroups.com.
On 12/26/22 14:39, Gonzalo Garramuño wrote:
It seems there's an issue with the NVidia drivers and Wayland.
I wonder if that's because of this infamous comment:
https://youtu.be/MShbP3OpASA?t=2927
It seems there's an issue with the NVidia drivers and Wayland.
OK. I also tried my application with OTHER_WAY on and, as long as my
mouse was in the window, it played back the movie correctly. As soon as
the mouse left the window, no playback continued.