-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
💔 |
@@ -49,10 +50,39 @@ export class AndroidApplicationManager extends ApplicationManagerBase { | |||
"1"]); | |||
|
|||
if (!this.$options.justlaunch) { | |||
let processIdentifier = await this.getProcessId(appIdentifier); | |||
if (processIdentifier) { | |||
let deviceIdentifier = this.adb.identifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you use this.adb.identifier
instead of this.identifier
// Information is returned in the following format | ||
// USER PID PPID VSIZE RSS WCHAN PC NAME | ||
// u0_a64 4831 488 851380 94888 ep_poll f1e43bb9 S org.nativescript.myApplication | ||
let processes = await this.adb.executeShellCommand(["ps"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of executing this and parsing the result, can't you use the $androidProcessService
: https://github.com/telerik/mobile-cli-lib/blob/master/mobile/mobile-core/android-process-service.ts#L206-L218
@@ -7,14 +7,14 @@ export class AndroidLogFilter implements Mobile.IPlatformLogFilter { | |||
|
|||
// sample line is "11-23 12:39:07.310 1584 1597 I art : Background sticky concurrent mark sweep GC freed 21966(1780KB) AllocSpace objects, 4(80KB) LOS objects, 77% free, 840KB/3MB, paused 4.018ms total 158.629ms" | |||
// or '12-28 10:45:08.020 3329 3329 W chromium: [WARNING:data_reduction_proxy_settings.cc(328)] SPDY proxy OFF at startup' | |||
private static API_LEVEL_23_LINE_REGEX = /.+?\s+?(?:[A-Z]\s+?)([A-Za-z ]+?)\s*?\: (.*)/; | |||
private static API_LEVEL_23_LINE_REGEX = /.+?\s+?(?:[A-Z]\s+?)([A-Za-z \.]+?)\s*?\: (.*)/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed? I couldn't understand it from the commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After personal discussion - the reason is that we have added a new tag, that has .
in it.
mobile/android/android-log-filter.ts
Outdated
let acceptedTags = ["chromium", "Web Console", "JS"]; | ||
private getConsoleLogFromLine(lineText: string, pid: string): any { | ||
// filter log line if it does not belong to the current application process id | ||
if (lineText.indexOf(pid) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in case we do not have pid, we'll always return null. But in case we have PID, we'll still apply the incorrect filters?
For iOS Simulator we have similar case, but the logic there is:
- in case there's a pid, find it in the logs and show each line that contains it
- in case we do not have a PID, apply the old filtering
Can't we do the same here?
mobile/android/android-log-filter.ts
Outdated
let match = lineText.match(AndroidLogFilter.LINE_REGEX) || lineText.match(AndroidLogFilter.API_LEVEL_23_LINE_REGEX); | ||
|
||
if (match && acceptedTags.indexOf(match[1].trim()) !== -1) { | ||
return { tag: match[1].trim(), message: match[2] }; | ||
} | ||
let matchingTag = _.some(acceptedTags, (tag: string) => { return lineText.indexOf(tag) !== -1; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line deleted? Its idea is to save us in cases where the logs are changed and our regex fails, but we still check if the line contains "chromium" for example.
@@ -6,7 +6,7 @@ interface IComposeCommandResult { | |||
} | |||
|
|||
export class DeviceAndroidDebugBridge extends AndroidDebugBridge implements Mobile.IDeviceAndroidDebugBridge { | |||
constructor(private identifier: string, | |||
constructor(public identifier: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you do not need this change as the only place where you are using the property outside of the current class is on a place, where you already have the identifier.
💔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests are failing.
Also, once we have an agreement for the expected behavior, new unit tests should be added for the new filtering.
let currentProcessLine = processes.find((line: Array<string>) => line[line.length - 1] === appId); | ||
|
||
if (!currentProcessLine) { | ||
return Promise.resolve(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need to return Promise here, async
keyword does this for you.
return null;
is enough
33354a9
to
189c7d1
Compare
💔 |
189c7d1
to
07d3a83
Compare
💔 |
@@ -49,6 +50,12 @@ export class AndroidApplicationManager extends ApplicationManagerBase { | |||
"1"]); | |||
|
|||
if (!this.$options.justlaunch) { | |||
let deviceIdentifier = this.identifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see you use 'let' in almost all cases, if there is no specific reason (if so what), you may consider updating your code. As you know declaring the variables with 'let' indicates the'll be changed and most of these are not. 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, thank you!
07d3a83
to
2ec92a7
Compare
💔 |
2ec92a7
to
6b3c100
Compare
💔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After green build.
Great work, I love the tests. 🥇
|
||
it("when API level 23 or later is used, and application pid doesn't match any logcat pids", () => { | ||
const appPid = "99999"; | ||
const expectedOutputMap = androidApiLevel23MapForPid8141.map((testData) => { return { input: testData.input, output: null } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can shorten this:
const expectedOutputMap = androidApiLevel23MapForPid8141.map(testData => ({ input: testData.input, output: null }) );
6b3c100
to
25cc134
Compare
💔 |
💔 |
Problem
NativeScript/nativescript-cli#2818 - When an app was started the CLI's logging filter would parse each incoming adb line and check it against a regex that either
JS:
was the tag used, or that any of the accepted tags's string was contained within the logcat line.That would at times return incorrect, or incomplete logs.
Proposed solution
Read the process id for the application process from adb, then filter logs by the pid.