-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
adb: Use uid
to limit logcat
to the current application
#131
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dvc94ch
approved these changes
Aug 26, 2023
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.
nice!
Having never really understood how Android Studio does it, I just stumbled upon this very new [stackoverflow answer] that has a rather beatiful solution to the current problems with `pidof`, without drawbacks. Pidof has always been flaky as it relies on the app to be running, which may either take some time or never happen if the app crashed before `pidof` is first run. This results in silly workarounds such as loops that induce extra delay and need to have an upper bound. And this `pid` changes every time the app is restarted, making it a tedious process that also doesn't react to manual app restarts on the device. Retrieving the `uid` via `pm list packages -U` on the other hand, and passing that to `logcat --uid` has the following advantages: - Always available immediately after the app has been installed, no need to check it in a loop (no extra delay); - Doesn't change after the app is (re!)installed, unless the user fully deletes and installs the app again; - Is resilient against app crashes because of that, and allows the user to see any error/crash related messages straight away; - Still includes logs printed by other system components that run or are invoked within an app, as before. [stackoverflow answer]: https://stackoverflow.com/a/76551835
MarijnS95
force-pushed
the
adb-logcat-uid
branch
from
August 26, 2023 17:22
01c71db
to
decd629
Compare
MarijnS95
added a commit
to rust-mobile/cargo-apk
that referenced
this pull request
Sep 11, 2023
This is a port of: rust-mobile/xbuild#131 rust-mobile/xbuild#135 Having never really understood how Android Studio does it, I just stumbled upon this very new [stackoverflow answer] that has a rather beatiful solution to the current problems with `pidof`, without drawbacks. Pidof has always been flaky as it relies on the app to be running, which may either take some time or never happen if the app crashed before `pidof` is first run. This results in silly workarounds such as loops that induce extra delay and need to have an upper bound. And this `pid` changes every time the app is restarted, making it a tedious process that also doesn't react to manual app restarts on the device. Retrieving the `uid` via `pm list packages -U` on the other hand, and passing that to `logcat --uid` has the following advantages: - Always available immediately after the app has been installed, no need to check it in a loop (no extra delay); - Doesn't change after the app is (re!)installed, unless the user fully deletes and installs the app again; - Is resilient against app crashes because of that, and allows the user to see any error/crash related messages straight away; - Still includes logs printed by other system components that run or are invoked within an app, as before. The only downside is that `pm list package` possibly returns multiple packages if there is a substring match; for this reason the code searches for an explicit match in the output. [stackoverflow answer]: https://stackoverflow.com/a/76551835
MarijnS95
added a commit
that referenced
this pull request
Sep 13, 2023
This effectively reverts commit bf478ad (#118) without touching code improvements elsewhere. `-W` makes app start-up significantly slower, sometimes leaving the user wait up to 10 seconds even if the app has already started and crashed without showing any `logcat` output. It has now become unnecessary since using the app `uid` as filter in #131, which is always available as long as the app is installed and doesn't rely on a running (**before** having crashed!) executable for a process id.
MarijnS95
added a commit
that referenced
this pull request
Sep 14, 2023
…er (#137) This effectively reverts commit bf478ad (#118) without touching code improvements elsewhere. `-W` makes app start-up significantly slower, sometimes leaving the user wait up to 10 seconds even if the app has already started and crashed without showing any `logcat` output. It has now become unnecessary since using the app `uid` as filter in #131, which is always available as long as the app is installed and doesn't rely on a running (**before** having crashed!) executable for a process id.
MarijnS95
added a commit
to rust-mobile/cargo-apk
that referenced
this pull request
Nov 21, 2023
This is a port of: rust-mobile/xbuild#131 rust-mobile/xbuild#135 Having never really understood how Android Studio does it, I just stumbled upon this very new [stackoverflow answer] that has a rather beatiful solution to the current problems with `pidof`, without drawbacks. Pidof has always been flaky as it relies on the app to be running, which may either take some time or never happen if the app crashed before `pidof` is first run. This results in silly workarounds such as loops that induce extra delay and need to have an upper bound. And this `pid` changes every time the app is restarted, making it a tedious process that also doesn't react to manual app restarts on the device. Retrieving the `uid` via `pm list packages -U` on the other hand, and passing that to `logcat --uid` has the following advantages: - Always available immediately after the app has been installed, no need to check it in a loop (no extra delay); - Doesn't change after the app is (re!)installed, unless the user fully deletes and installs the app again; - Is resilient against app crashes because of that, and allows the user to see any error/crash related messages straight away; - Still includes logs printed by other system components that run or are invoked within an app, as before. The only downside is that `pm list package` possibly returns multiple packages if there is a substring match; for this reason the code searches for an explicit match in the output. [stackoverflow answer]: https://stackoverflow.com/a/76551835
MarijnS95
added a commit
to rust-mobile/cargo-apk
that referenced
this pull request
Nov 22, 2023
This is a port of: rust-mobile/xbuild#131 rust-mobile/xbuild#135 Having never really understood how Android Studio does it, I just stumbled upon this very new [stackoverflow answer] that has a rather beatiful solution to the current problems with `pidof`, without drawbacks. Pidof has always been flaky as it relies on the app to be running, which may either take some time or never happen if the app crashed before `pidof` is first run. This results in silly workarounds such as loops that induce extra delay and need to have an upper bound. And this `pid` changes every time the app is restarted, making it a tedious process that also doesn't react to manual app restarts on the device. Retrieving the `uid` via `pm list packages -U` on the other hand, and passing that to `logcat --uid` has the following advantages: - Always available immediately after the app has been installed, no need to check it in a loop (no extra delay); - Doesn't change after the app is (re!)installed, unless the user fully deletes and installs the app again; - Is resilient against app crashes because of that, and allows the user to see any error/crash related messages straight away; - Still includes logs printed by other system components that run or are invoked within an app, as before. The only downside is that `pm list package` possibly returns multiple packages if there is a substring match; for this reason the code searches for an explicit match in the output. [stackoverflow answer]: https://stackoverflow.com/a/76551835
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having never really understood how Android Studio does it, I just stumbled upon this very new stackoverflow answer that has a rather beatiful solution to the current problems with
pidof
, without drawbacks. Pidof has always been flaky as it relies on the app to be running, which may either take some time or never happen if the app crashed beforepidof
is first run. This results in silly workarounds such as loops that induce extra delay and need to have an upper bound. And thispid
changes every time the app is restarted, making it a tedious process that also doesn't react to manual app restarts on the device. Retrieving theuid
viapm list packages -U
on the other hand, and passing that tologcat --uid
has the following advantages: