Skip to content
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

LVGL with Wayland on Embedded Linux #225

Closed
symfund opened this issue Jun 26, 2022 · 8 comments
Closed

LVGL with Wayland on Embedded Linux #225

symfund opened this issue Jun 26, 2022 · 8 comments
Labels

Comments

@symfund
Copy link

symfund commented Jun 26, 2022

All controls can receive the touch events, but do not redraw the display.

https://github.com/symfund/lvgl-port-ma35d1/blob/master/IMG_2781.PNG

@kisvegabor kisvegabor transferred this issue from lvgl/lv_port_linux Jun 28, 2022
@kisvegabor
Copy link
Member

I moved the issue to the driver's repository.

@simplejack-src. do you have any ideas?

@ghost
Copy link

ghost commented Jun 28, 2022

Quick look at main.c in your repository, it seems as though you forgot to setup the struct pollfd pfd; structure. Adding something like below (before your while (1) loop) will wait until new incoming data is received on the Wayland file descriptor/pipe:

pfd.fd = lv_wayland_get_fd();
pfd.events = POLLIN;

In addition if you want to wait and loop again if the Wayland TX pipe gets full, you can add (before the actual poll(...)):

if (lv_wayland_window_is_flush_pending(NULL)) {
   pfd.events |= POLLOUT;
} else {
   pfd.events &= (~POLLOUT);
}

@symfund
Copy link
Author

symfund commented Jun 28, 2022

Thank @simplejack-src for your help.
Thank @kisvegabor for your excellent LVGL!

LVGL natively supports Wayland is awesome.

@simplejack-src I added the setup code for pfd. The problem still existed.

For debugging, after creating the calendar LV object, add event callback:

lv_obj_t *calendar = lv_calendar_create(lv_scr_act());
lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);

The event handler 'event_handler' actually recieved all the touch events.
But in calendar's header dropdown button event handler, no touch event incomed at all!

That says, if not add the debug 'event_handler', the default calendar's class event handler actually recieved all the events.

BTW, I use the deprecated WL-SHELL.

https://github.com/symfund/lvgl-port-ma35d1/blob/master/gadgets.png

@symfund
Copy link
Author

symfund commented Jun 29, 2022

I found the problem! UI does not render because the backing buffer is always busy.

@symfund
Copy link
Author

symfund commented Jun 29, 2022

In _lv_wayland_flush(), It seems no harm to comment out the following lines:

#if 0

else if (buffer->busy)
{
lv_disp_flush_ready(disp_drv);
return;
}

#endif

When touch the calendar's YEAR dropdown, the popup dropdown list appears.

@ghost
Copy link

ghost commented Jun 29, 2022

That check is needed to enforce the Wayland protocol. Effectively, it ensures that the buffer that was "sent" (committed) to the compositor isn't touched by the client until the corresponding release event is received (indicating that the client can reuse that buffer). Since this driver is single-buffered, we need to wait until the compositor releases that buffer before we can begin drawing on it again.

If that section is being hit (should generate an LVGL warning), it would imply that the compositor hasn't released the buffer back to the client by the time it was looking to draw the new frame (LVGL's flush call).

I'll have to think about a proper fix for this. I think the easiest would probably be to go double-buffered, and only commit a single surface/buffer at a time...

@ghost
Copy link

ghost commented Jun 29, 2022

Further thinking on it, a proper fix (which I somewhat lament, as I've been just adding bandage fixes until I can do a full refactor) would be to replace the simple linear buffer allocator with a fixed-size free list and dynamically allocate backing buffers for LVGL to flush into. This keeps LVGL happy (not blocking it's flush routine), would only drop frames on memory starvation, and stays responsive (if flushes occur too often, frame-limiting could also be added).

Unfortunately, as this will be a decently substantial change it'll be a few weeks until I get to it (anyone else wanting to tackle it sooner though is always welcome :)).

@stale
Copy link

stale bot commented Apr 20, 2023

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 20, 2023
@symfund symfund closed this as completed Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants