Timer in app stalls while evaluating function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is in Matlab 2022a. The function the timer calls sends a udp message and updates a plot. I'm hoping somebody recognizes this error because I'm having trouble telling where it's getting stuck. The timer stalls somewhere in this function (pollBoardA), and if I hit ctrl-c it breaks out and prints the following message. I can then restart the timer and everything works again. I have not found a reliable way to make this happen but it's happening pretty often. I suspect it's related to the plotting but haven't confirmed it yet since the problem is intermittent.
Operation terminated by user during pollBoardA
In timer/timercb (line 114)
feval(val{1}, obj, eventStruct, val{2:end});
In matlab.ui.internal.componentframework.services.optional.EventDispatcherAddOn>@()obj.ProxyView.sendEventToClient('flush',pvPairs) (line 77)
func = @() obj.ProxyView.sendEventToClient('flush', pvPairs);
In matlab.ui.internal.dialog.DialogHelper.dispatchWhenPeerNodeViewIsReady (line 276)
func()
In matlab.ui.internal.componentframework.services.optional.EventDispatcherAddOn/sendFlushEventToClient (line 79)
matlab.ui.internal.dialog.DialogHelper.dispatchWhenPeerNodeViewIsReady(model, obj.ProxyView, func, obj);
7 commentaires
Geoff Hayes
le 22 Août 2022
I'm not sure what (or if) there is a limit on how fast you can request data. If you could lower the rate, it would be interesting to see if the problem still occurs.
Réponses (1)
Sanchari
le 28 Déc 2023
Hello Jane,
I understand that you want to resolve the error message which indicates that the MATLAB operation was terminated due to a user interrupt (Ctrl+C) during the execution of the “pollBoardA” function.
Based on the provided information, it looks like is called by a timer callback. When you press Ctrl+C, MATLAB throws an error and displays the stack trace of where it was in the execution process when the interruption occurred.
The stack trace points towards an issue related to the timer callback and the flushing of events to the client, which is likely related to the graphics rendering or the GUI update.
Here are some steps you can take to troubleshoot and potentially resolve the issue:
- Isolate the Problem: Try to isolate the problem by temporarily removing the plotting code from the ‘pollBoardA’ function. If the timer no longer stalls, it suggests that the plotting is indeed related to the issue. You've mentioned that disabling plot updates did not resolve the issue, so the next step is to look at the UDP communication.
- Check UDP Operations: Ensure that UDP operations are not blocking the MATLAB thread. If the write operations to the UDP port are waiting for some event that never occurs, they could hang the function. You could add some debug prints before and after the UDP write calls to see if they are completing successfully.
- Use Asynchronous Plot Updates: The ‘drawnow’ function forces MATLAB to perform all pending graphical updates, which can be a blocking operation. Consider using ‘drawnow limitrate’ or ‘drawnow update’ to perform quicker, less resource-intensive updates.
- Debugging: Use MATLAB's debugging tools to set breakpoints and step through the ‘pollBoardA’ function to see exactly where it might be getting stuck.
- Error Handling: Implement error handling within your ‘pollBoardA’ function to catch any issues that arise during its execution. This can help prevent the timer from stalling.
- Check for Resource Leaks: Check if system resources are being exhausted. For example, if the buffer ‘app.bufferin’ grows indefinitely, it could be consuming too much memory, leading to performance issues.
- Check for Infinite Loops or Deadlocks: Ensure that there are no infinite loops or deadlocks within the callback or any related code, especially if there are dependencies between the timer callback and other parts of your application.
Check out this MathWorks documentation for ‘drawnow’ function usage: https://www.mathworks.com/help/matlab/ref/drawnow.html?searchHighlight=drawnow%20limitrate&s_tid=srchtitle_support_results_1_drawnow%20limitrate
For more information on related queries, I recommend the following resources:
- App timer slows when mousing over plot: https://www.mathworks.com/support/search.html/answers/1814705-app-timer-slows-when-mousing-over-plot.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/desktop-tools-and-development-environment&page=1
- Ending a function after a time duration: https://www.mathworks.com/support/search.html/answers/291401-ending-a-function-after-a-time-duration.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/control-flow&page=1
- Appdesigner GUI issue code: https://www.mathworks.com/support/search.html/answers/1614760-appdesigner-gui-issue-code.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/app-designer&page=1
Hope this information is helpful to you!
0 commentaires
Voir également
Catégories
En savoir plus sur Install Products dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!