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

StackOverflowError inside UiAutomatorTestRunner #10204

Closed
jlennox opened this issue Feb 15, 2018 · 15 comments
Closed

StackOverflowError inside UiAutomatorTestRunner #10204

jlennox opened this issue Feb 15, 2018 · 15 comments
Assignees
Labels
Android related to Android-native driver(s) Bug a problem that needs fixing ThirdParty upstream problems

Comments

@jlennox
Copy link

jlennox commented Feb 15, 2018

The problem

When establishing a new Chrome session Appium exits unexpectedly. The device logs show there was a StackOverflowError inside UiAutomatorTestRunner.

This is a continuation from issue #10126

Environment

  • Appium version (or git revision) that exhibits the issue: 1.7.1
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: OS X 12.12.5
  • Node.js version (unless using Appium.app|exe): v9.4.0
  • Mobile platform/version under test: Android 8.1
  • Real device or emulator/simulator: Real. Nexus 5x.
  • Appium CLI or Appium.app|exe: CLI

Details

I am seeing this when starting a session for Chrome. The time stamps on the side of the two logs are from the same clock.

Updating my Nexus 5x to 8.1.0 (OPM5.171019.015, Feb 2018) and the latest Chrome 64.0.3282.137 appears to of triggered this behavior. Updating a another Nexus 5x from 7.x and an earlier chrome to be about the same has also caused this to begin happening on it. I do not see this happening on any of my other devices, which are predominately older versions of Android/Chrome.

Rebooting the devices does not change the outcome. It happens about 50% of the time regardless.

The issue is triggered by:
https://github.com/appium/appium-android-bootstrap/blob/master/bootstrap/src/io/appium/android/bootstrap/utils/TheWatchers.java#L51

The returned value and any side affects appear to be completely void piped? The only consumer is: https://github.com/appium/appium-android-bootstrap/blob/e0df190e35baccf31b4e2af81db75cff580631a1/bootstrap/src/io/appium/android/bootstrap/SocketServer.java#L140

Enabling the capability disableAndroidWatchers appears to "fix" the issue, but has the side effect of disabling what appears to be otherwise very nice condition checks: https://github.com/appium/appium-android-bootstrap/blob/master/bootstrap/src/com/android/uiautomator/common/UiWatchers.java#L39

I do not know if what appears to be dead code that triggers this issue was removed/"fixed" if this issue would surface inside the other watchers.

Link to Appium logs

Device logs: https://gist.github.com/jlennox/b2936ba04f53f41916c3778331f10b36
Appium logs: https://gist.github.com/jlennox/3639901543c1347ed221484535cd6f4b

@trix0
Copy link
Contributor

trix0 commented Feb 15, 2018

Go ask on stackoverflow then ? Its theirs error LUL 🤣 JK

@mykola-mokhnach
Copy link
Collaborator

@trix0 Flooding is not appreciated here

@mykola-mokhnach mykola-mokhnach added Bug a problem that needs fixing Android related to Android-native driver(s) labels Feb 15, 2018
@mykola-mokhnach
Copy link
Collaborator

@imurchie @vmaxim Any ideas?

@imurchie
Copy link
Contributor

No particular idea, no. Android 8.1 shoudl be tested with UIAutomator2 is my first thought.

@jlennox
Copy link
Author

jlennox commented Feb 15, 2018

Android 8.1 shoudl be tested with UIAutomator2 is my first thought.

Can you explain this statement or provide a link to a place with more information? The readme.md for UIAutomator2 does not provide any reason this would be the case.

@vmaxim
Copy link
Contributor

vmaxim commented Feb 15, 2018

@jlennox Are you able to get page source of this particular view via uiautomatorviewer or adb shell uiautomator dump?

@jlennox
Copy link
Author

jlennox commented Feb 15, 2018

I ran uiautomator dump ten times in a row and verified the contents of /sdcard/window_dump.xml each time without issue.

@mykola-mokhnach mykola-mokhnach added the ThirdParty upstream problems label Feb 16, 2018
@viccky88
Copy link

viccky88 commented Feb 16, 2018

I am also facing the same issue. It is intermittent and happening on Android 6, 7 & 8 OS versions. So it is not related to only Android 8.0.
Switching to uiAutomator2 resolves the issue but uiAutomator should also work for any Android version above KitKat.

@jlennox
Copy link
Author

jlennox commented Feb 16, 2018

@viccky88 Because it appeared related in my case, what Chrome/webview versions are on those devices?

@viccky88
Copy link

@jlennox I am testing native app.

@kevinyosua
Copy link

hi guys, we experienced this issue after update to Android System Webview (61.0.3163.98).

After we downgrade the webview and use 60 *we also use chromedriver 2.33 because 2.35 only support webview v.62) this issue not happening again.

@jlennox
Copy link
Author

jlennox commented Feb 28, 2018

@imurchie @mykola-mokhnach This issue is still happening using uiautomator2.

AccessibilityNodeInfoDumper.java will infinitely recurse on accessibility nodes which have a self referential tree, which appears to of become a thing in a newer version of Chrome.

Appium version: 1.7.1
Device: Android 8.1.0
Appium logs: https://gist.github.com/jlennox/2786cc1b636e47b48ddc0f6b55701ee8
Device logs: https://gist.github.com/jlennox/41bad1a2ad66351838cd7da064084770
The stack:

 Fatal error while handling action in: io.appium.uiautomator2.handler.Source
 java.lang.StackOverflowError: stack size 1037KB
 	at java.lang.StringBuffer.append(StringBuffer.java:367)
 	at java.io.StringWriter.write(StringWriter.java:94)
 	at org.kxml2.io.KXmlSerializer.flushBuffer(KXmlSerializer.java:80)
 	at org.kxml2.io.KXmlSerializer.append(KXmlSerializer.java:61)
 	at org.kxml2.io.KXmlSerializer.append(KXmlSerializer.java:75)
 	at org.kxml2.io.KXmlSerializer.attribute(KXmlSerializer.java:491)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:109)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 
    [Many lines excluded]
 
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:127)
 	at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.getWindowXMLHierarchy(AccessibilityNodeInfoDumper.java:78)
 	at io.appium.uiautomator2.utils.XMLHierarchy.getRawXMLHierarchy(XMLHierarchy.java:62)
 	at io.appium.uiautomator2.utils.XMLHierarchy.getRawXMLHierarchy(XMLHierarchy.java:58)
 	at io.appium.uiautomator2.utils.XMLHierarchy.getFormattedXMLDoc(XMLHierarchy.java:68)
 	at io.appium.uiautomator2.handler.Source.safeHandle(Source.java:37)
 	at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:56)
 	at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:202)
 	at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:193)
 	at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
 	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
 	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
 	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
 	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
 	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
 	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
 	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
 	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
 	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
 	at java.lang.Thread.run(Thread.java:764)

@jlennox
Copy link
Author

jlennox commented Feb 28, 2018

The issue inside Google's tracker: https://bugs.chromium.org/p/chromium/issues/detail?id=805014

This said, it being possible and happening, AccessibilityNodeInfoDumper.java should include a settable depth limit on recursion.

@mykola-mokhnach
Copy link
Collaborator

@lock
Copy link

lock bot commented May 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators May 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android related to Android-native driver(s) Bug a problem that needs fixing ThirdParty upstream problems
Projects
None yet
Development

No branches or pull requests

7 participants