android / performance-samples

Samples to show APIs and best practices in Performance on Android
https://d.android.com/topic/performance/overview
Apache License 2.0
1.27k stars 214 forks source link

java.io.FileNotFoundException: http://localhost:9001/status - PerfettoHttpServer #277

Closed slycodemonkey closed 8 months ago

slycodemonkey commented 8 months ago

Using v1.2.3 of the benchmark-macro library on an emulator is yielding the below error which hangs my test.

I have attempted to add android:usesCleartextTraffic="true" to my instrumentation apk and confirmed that it was present in the merged manifest for the instrumentation apk. I also did a get request to the same url via adb shell which yielded a http status code 200 via "nc localhost 9001" with a "GET /status HTTP/1.1" request which yielded the following response for the perfetto server:

HTTP/1.1 200 OK Cache-Control: no-cache Content-Type: application/x-protobuf Transfer-Encoding: identity Content-Length: 73 Connection: keep-alive

I do notice that the perfetto log for starting the server successfully happens after the failure so I'm wondering if there's a race between the 2 processes.

03-11 23:23:12.827  6794  6816 E TestRunner: java.io.FileNotFoundException: http://localhost:9001/status
03-11 23:23:12.827  6794  6816 E TestRunner:    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.perfetto.server.PerfettoHttpServer.httpRequest(PerfettoHttpServer.kt:289)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.perfetto.server.PerfettoHttpServer.httpRequest$default(PerfettoHttpServer.kt:270)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.perfetto.server.PerfettoHttpServer.status(PerfettoHttpServer.kt:263)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.perfetto.server.PerfettoHttpServer.isRunning(PerfettoHttpServer.kt:185)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.perfetto.server.PerfettoHttpServer.startServer(PerfettoHttpServer.kt:135)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.perfetto.PerfettoTraceProcessor.startServer(PerfettoTraceProcessor.kt:289)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.perfetto.PerfettoTraceProcessor.access$startServer(PerfettoTraceProcessor.kt:74)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.perfetto.PerfettoTraceProcessor$Companion.runServer(PerfettoTraceProcessor.kt:101)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.MacrobenchmarkKt.macrobenchmark(Macrobenchmark.kt:241)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.MacrobenchmarkKt.macrobenchmarkWithStartupMode(Macrobenchmark.kt:422)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.junit4.MacrobenchmarkRule.measureRepeated(MacrobenchmarkRule.kt:107)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.junit4.MacrobenchmarkRule.measureRepeated$default(MacrobenchmarkRule.kt:97)
03-11 23:23:12.827  6794  6816 E TestRunner:    at XXXXXXX.ColdStartNoneTest.coldStart(ColdStartNoneTest.kt:23)
03-11 23:23:12.827  6794  6816 E TestRunner:    at java.lang.reflect.Method.invoke(Native Method)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
03-11 23:23:12.827  6794  6816 E TestRunner:    at com.facebook.testing.jetpackbenchmark.JetpackBenchmarkRunner$2.evaluate(JetpackBenchmarkRunner.java:82)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.benchmark.macro.junit4.MacrobenchmarkRule$applyInternal$1.evaluate(MacrobenchmarkRule.kt:133)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:136)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.Suite.runChild(Suite.java:128)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.Suite.runChild(Suite.java:27)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
03-11 23:23:12.827  6794  6816 E TestRunner:    at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67)
03-11 23:23:12.827  6794  6816 E TestRunner:    at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
03-11 23:23:12.827  6794  6816 E TestRunner:    at com.facebook.testing.instrumentation.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:497)
03-11 23:23:12.827  6794  6816 E TestRunner:    at com.facebook.testing.instrumentation.FbInstrumentationTestRunner.onStart(FbInstrumentationTestRunner.java:198)
03-11 23:23:12.827  6794  6816 E TestRunner:    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2211)
03-11 23:23:12.830  6953  6953 W perfetto:             httpd.cc:99 [HTTP] Starting RPC server on localhost:9001
03-11 23:23:12.831  6953  6953 I perfetto:            httpd.cc:104 [HTTP] This server can be used by reloading https://ui.perfetto.dev and clicking on YES on the "Trace Processor native acceleration" dialog or through the Python API (see https://perfetto.dev/docs/analysis/trace-processor#python-api).
slycodemonkey commented 8 months ago

Created issue in IssueTracker.