-
-
Notifications
You must be signed in to change notification settings - Fork 356
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
LUA Widgets: background() not called if menu is active #4279
Comments
I'm not sure there is an easy way to do this. The menus (system, model and screen setup) take over and everything on the main view stops. |
It worked in 2.7. Was that a deliberate change in 2.8? |
2.7 did not use LVGL. |
2.7 also called LUA widget background processing through luawidget::checkEvents() which hasn't changed since. Where was luawidget::checkEvents() called from in 2.7? |
That was before my time. I guess that opening a menu did not block the underlying views and they continued to run. |
We need to call luawidget::background() directly if the menus are running. At what rate is checkEvents() called if the main view is active? |
That's potentially difficult (have to iterate all screens and all widgets, including top bar, on all screens). In my opinion the current behaviour is correct. |
I have a niggling feeling this was deliberate, but can immediately place a finger on the issue/PR this was discussed in. IIRC it was to do with slowdowns in the menus, due to widget background behaviour? I get the desire to have a widget working in the background all the time, but with the current architecture, I can't see that ending well in the long term. |
Well AFAIR there was discussion once about that with 2.8 |
I have the opposite problem - I struggle to think of a scenario where this actually matters. I mean, how much time would/should you actually spend looking at a setup screen when a model is connected and active? |
If this is a concern we have a problem. Function scripts run continuously in the background, hence also while menus are active. So I think this can't be a point against running LUA widget code in the background.
It's not about running a widget in the background all the time. It's about allowing widgets to continue processing (like continuing to integrate a parameter) even if not on display. This is why I agree with Robert. Starting with 2.8 LUA widgets don't work like advertised. The background processing feature of LUA widgets got mutilated with 2.8. Architectural concerns are valid as in does calling checkEvents() while menus are active fit into the menus concept. As I understood, no. Idea: If there was a way to detect if menus are active we could add calling luawidget::background() outside the menus code to cover the other half of background processing. |
@mha1 100% agree. |
PR #4393 adds logic to call the widget background functions when in the setup pages. It needs extensive testing before being considered for merging into main. |
@philmoz Hi Phil, I hacked a little widget script iteratively calculating Pi using the Nilakantha series in the widget's background function. With the number of iterations set by the widget's settings you can adjust the load background() will put on the system. Once you cross a certain boundary of iterations (about 1450 on my NV14) the script will be killed due to hitting the allowed max CPU limit. This happens as expected with no side effects on the main system just like it should. Being close to the CPU limit (1425 iterations) the GUI is still responsive with no major lag or other side effects. I think you PR works fine. To use: unzip bckgrnd.zip and put the folder |
Is there an existing issue for this problem?
What part of EdgeTX is the focus of this bug?
Transmitter firmware
Current Behavior
LUA widgets can be updated even if they are currently not on screen, e.g. by having a different main view on screen. 2.7 also called the widget's background() function in case a menu like model settings was selected. 2.8, 2.9 and current main don't call background() if a menu is selected. This causes problems for some LUA scripts relying on continuous foreground and background processing.
Expected Behavior
As in 2.7 LUA needs to call the LUA widget's background() function in all cases where the widget is not on screen which is also the case for active menus.
Steps To Reproduce
Version
2.9.1
Transmitter
Radiomaster TX16S / TX16SMK2
Operating System (OS)
No response
OS Version
No response
Anything else?
@philmoz I think you might be able to help. The LUA background() function is invoked by
void LuaWidget::checkEvents()
which is called if the widget is visible or not visible and in a different main view but not called if a menu is active.The text was updated successfully, but these errors were encountered: