MobileNativeFoundation / bluepill

Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine
BSD 2-Clause "Simplified" License
3.19k stars 232 forks source link

trace-profile.json is not a valid json #437

Open RainNapper opened 4 years ago

RainNapper commented 4 years ago

The trace-profile.json uses "nan" in some entries. I do not know exactly under what circumstances "nan" is used, but when this file is loaded by chrome://tracing, it will throw an error for an invalid character. Error:

While importing:
SyntaxError: Unexpected token a in JSON at position 6502
    at JSON.parse (<anonymous>)
    at new TraceEventImporter (chrome://tracing/tracing.js:5498:19)
    at Import.createImporter_ (chrome://tracing/tracing.js:1332:8)
    at chrome://tracing/tracing.js:1326:167
    at Task.run (chrome://tracing/tracing.js:2553:95)
    at runAnother (chrome://tracing/tracing.js:2556:371)
    at runTask (chrome://tracing/tracing.js:2321:57)
    at processIdleWork (chrome://tracing/tracing.js:2326:116)
    at window.requestIdleCallback.timeout (chrome://tracing/tracing.js:2319:81)

Example line:

{"name":"CPU", "ph": "C", "ts": "1587074269993629", "pid": 1, "args": {"sys": nan, "usr": nan, "idle": nan}},

In the meantime, I've been able to work around this issue using:

cat trace-profile.json | sed "s/nan/0/g" > trace-profile-fixed.json
ravimandala commented 4 years ago

Thanks for the temporary fix. I guess some missing entries are breaking the trace profile json. Bluepill should be outputting 0 or something appropriate. I will take a look.

chenxiao0228 commented 3 years ago

@RainNapper nan means NotANumber.

This looks like a bad exception handling. Will look into it. Thanks for reporting!