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

ANR issues due to getSubNodes recursion depth #28

Open
saurabhkumar8112 opened this issue Feb 24, 2024 · 1 comment
Open

ANR issues due to getSubNodes recursion depth #28

saurabhkumar8112 opened this issue Feb 24, 2024 · 1 comment

Comments

@saurabhkumar8112
Copy link

When iterating through the child nodes of a parent node, the method onAccessibilityEvent invokes getSubNodes, a recursive function. This recursion, influenced by the depth of the tree (treeDepth), has the potential to cause a stack overflow, leading to Application Not Responding (ANR) errors.

There are discussions on StackOverflow, of ANRs occurring when the accessibility service is used for navigating through AccessibilityNodeInfo.

To mitigate this issue, I propose to add a new parameter, maximumTreeDepth, which would serve as a threshold for the recursion depth. Once this threshold is reached, further traversal operations would be halted, and the method getNextTexts can return.

This approach allows users to balance the trade-off between performance aspects (such as minimizing ANRs and reducing battery consumption) and usability, by adjusting the maximumTreeDepth parameter according to the needs of their specific application.

Let me know what do you think about it, I can then raise a PR for the same!

@X-SLAYER
Copy link
Owner

yes that's what i though about it will be better if you can raise an PR about this so we could test that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants