Nvda hangs when ui freezes
Steps to reproduce: I put a java code that, when runs, launches a UI with a button and a textbox. When the button is pressed, it puts the thread to sleep, causing the UI to freeze. During this time, NVDA hangs and becomes silent until the thread resumes. Actual behavior:
NVDA hangs and becomes unresponsive. Expected behavior:
NVDA should announce "blank" or "app is not responding" when the UI freezes. NVDA logs, crash dumps and other attachments: Will be attached. System configuration NVDA installed/portable/running from source: Installed. NVDA version: 2024.2 Windows version: Windows 11 64-bit, Version 23H2 (OS Build 22631.3737) Name and version of other software in use when reproducing the issue: Other information about your system: Other questions Does the issue still occur after restarting your computer? Yes. Have you tried any other versions of NVDA? If so, please report their behaviors. No. If NVDA add-ons are disabled, is your problem still occurring? Yes. Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu? Yes.
I recently created #16741 and #16740 and if you think this is the main cause of the issue, you can close them.
This is the code for mentioned UI. Just coppy in a filed called FreezeApp.java and then open cmd. issue javac FreezeApp.java java FreezeApp And then it launches.
```java
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class FreezeApp {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> createAndShowGUI());
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("Freeze App Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton freezeButton = new JButton("Freeze App");
JTextField textField = new JTextField(20); // 20 columns wide
freezeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Simulate a long-running task that freezes the UI
try {
Thread.sleep(10000); // Sleep for 10 seconds
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
});
JPanel panel = new JPanel();
panel.add(new JLabel("Enter text:"));
panel.add(textField);
panel.add(freezeButton);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}
This is similar to #14759
If you want to test this without coding, you can open the Run dialog, enter \1.2.3.4 and press Enter. You will see that NVDA freezes.
If I hit WinKey + R, and enter this in the edit box: \1.2.3.4 then hit Enter, neither NVDA 2023.3beta1 (installed) nor NVDA 2023.2 (portable) freezes.
The error dialog is announced, the actual dialog text is not, and the OK button is announced for both circumstances.
Thanks for testing with the previous versions. Did you test it with Nvda 2024.2?
On Mon, Jul 1, 2024 at 11:10 PM Brian Vogel @.***> wrote:
If I hit WinKey + R, and enter this in the edit box: \1.2.3.4 then hit Enter, neither NVDA 2023.3beta1 (installed) nor NVDA 2023.2 (portable) freezes.
The error dialog is announced, the actual dialog text is not, and the OK button is announced for both circumstances.
— Reply to this email directly, view it on GitHub https://github.com/nvaccess/nvda/issues/16749#issuecomment-2200888848, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALUYRAYKXKN3I3XWAF6F2MLZKGWDXAVCNFSM6AAAAABJ6QOVZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBQHA4DQOBUHA . You are receiving this because you authored the thread.Message ID: @.***>
-- hamidreza
Did you test it with Nvda 2024.2?
Sorry, two sequential typos on my part. I meant 2024.2 (portable) and 2024.3beta1 (installed). I have not had any NVDA 2023 version that I'm using since 2024.1 hit the street.
Hi,
I cannot reproduce either with alpha-32687,62c9122c (2024.4 alpha). Does this also occur with Narrator? If not, then we could look a bit more into NVDA side of things. Also, I know you may have tried, but try running the Run dialog example right after signing out and back in BEFORE running any Java apps.
Thanks.
I was able to reproduce this with the provided java code. Interestingly enough, if you start the app and then launch NVDA, the freeze doesn't occur. This is of course not a normal use case, I only mention this in case it's helpful identifying what root cause is. NVDA: v2024.3b1 Windows: 11 pro 23H2 22631.3810
This is similar code in python that does the same thing. For java stuff, because java access bridge also involved, I'm not sure its a same bug or not but if you copy this into a file like gui.py and open cmd and run python gui.py and then click on the button, it will cause Nvda to become silent and freezes. You should also installed WXPython.
import wx
import time
class MyFrame(wx.Frame):
def __init__(self, *args, **kw):
super(MyFrame, self).__init__(*args, **kw)
panel = wx.Panel(self)
self.textbox = wx.TextCtrl(panel, pos=(20, 20), size=(300, 30))
self.button = wx.Button(panel, label="Freeze UI for 10 seconds", pos=(20, 60))
self.button.Bind(wx.EVT_BUTTON, self.on_button_click)
self.SetTitle('Simple GUI')
self.SetSize((400, 200))
self.Centre()
def on_button_click(self, event):
# Freeze the UI for 10 seconds using time.sleep
self.button.Disable() # Disable the button to prevent multiple clicks
time.sleep(10) # Freeze the UI for 10 seconds
self.button.Enable() # Re-enable the button
wx.MessageBox('UI is now unfrozen', 'Info', wx.OK | wx.ICON_INFORMATION)
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None)
self.frame.Show(True)
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()
I ran the provided program in Java, NVDA froze for 10 seconds, which should be the case, but then NVDA unfroze and didn't crash. It is better that NVDA does not depend on the application that is running so that the user can check the status of applications even if one of applications freezes. I attached the NVDA log.
Yes @shadyar You're right Nvda just frozen for ten sec because Thread sleeps just for ten sec. If you increase the time, Nvda freezes for that time. I checked with my friend's computer and in one of experiments, Nvda could not be recovered so I edited my initial comment. Now, I revert back my initial comment. Thanks.
In my opinion, this situation is very common. It does affect NVDA users.
\\1.2.3.4 is an example.
cc @jcsteh Just asking politely if you have any thoughts on this.
NVDA works on other windows in my experience while it has been frozen on this window. I think either at the best reading components of the frozen windows can be suitable or at least NVDA should say "the windo is not responding" on the frozen window.
Does NVDA allow you to access other applications when it freezes in this scenario? That is, can you alt+tab out of the frozen app and go on using another app? It should and there is explicit code to allow for this, but that code is fragile and has broken on various occasions in the past, which is why I ask. https://github.com/nvaccess/nvda/issues/16749#issuecomment-2222613344 suggests that this works correctly for @shadyar, but I'm curious about @hamidrezaabroshan and others. If that isn't working, that's definitely something that needs to be addressed.
On the other hand, reporting "not responding" or similar immediately as soon as the app freezes is far less feasible. NVDA can't know whether an app is just taking a while or has actually frozen, so it has a timeout of 10 seconds before it cancels any requests. An exception is if the user switches applications, in which case NVDA immediately cancels any pending queries. We could decrease 10 seconds to some lower timeout, but there's a risk that this would cause unnecessary failures for an app or system that is running very slowly for whatever reason, which might make things worse for the user.
As a side note, Windows itself doesn't provide any proper or supported way to set a timeout for accessibility calls, so NVDA has a bunch of awful hacks to implement this (including hooking some Windows system calls), which is why it's fragile. Obviously, that doesn't change the severity from a user perspective, but hopefully this helps explain why this keeps coming up over and over again.
@jcsteh I see, it's reasonable. This suggestion might help users. After 5 secs and Before 10 secs freezing, NVDA can say "The Window is processing" or something similar and then after timeout it can say "The window is not responding".
A question: Is it possible technically when a window needs more time to respond or it is not responding, a user can navigate on components of the window by focus mode or navigation mode of NVDA for example just for reading information written on the window Regardless of whether this possibility has been implemented or not?
@jcsteh When I run the java sample and click on freezeApp button, if I press alt+tab instantly, nvda works on other windows but if I stay for 2 sec and then press alt+tab, it mutes until the app unfreezes.
Is it possible technically when a window needs more time to respond or it is not responding, a user can navigate on components of the window by focus mode or navigation mode of NVDA for example just for reading information written on the window Regardless of whether this possibility has been implemented or not?
No. When an app stops responding, you can't query it at all, and querying it is necessary to report any information inside the application.
if I stay for 2 sec and then press alt+tab, it mutes until the app unfreezes.
Okay. It sounds like watchdog (the part of NVDA responsible for trying to prevent such hangs) is unable to kill some hanging query. I just realised that this may well make sense in a Java Swing application, since I don't think we have a way to kill queries made with Java Access Bridge.
To help with diagnosis here, please do the following:
- For the Java application, provide an NVDA debug log where you try to alt+tab out of the application while it is frozen and where NVDA fails to recover.
- Similar for cases other than Java where you experience this.
Referencing issue #14396 I created some years ago with the same problem.