Android crash logs are hidden if phone and computer times aren't in sync #1146
Labels
android
The issue relates to Android mobile support.
bug
A crash or error in behavior.
good first issue
Is this your first time contributing? This could be a good place to start!
Describe the bug
If an Android app is well behaved, Briefcase will start the app, detect the PID of the running app, then display the logs for that PID.
If an app crashes on startup, there may not be enough time for Briefcase to detect the PID; in this case, Briefcase moves into a fallback mode, and prints the last 10 seconds of logs from any PID, with a filter that captures important Toga/Chaquopy log sections.
Briefcase establishes this "10 second" window by using the local system time. However, this timestamp is passed to
adb
as a log filter (-t
), and it is the phone's clock that is used to evaluate the log filter.So - if the computer and the phone disagree on the current time, it is possible for the app logs to appear empty, even though there are plenty of logs - just outside the "10 second" window.
Steps to reproduce
raise Exception()
at the top ofapp.py
It may be necessary to use a physical phone; an emulator will be using the host system clock.
Expected behavior
Logs for the crash should be generated in Briefcase.
Screenshots
No response
Environment
Logs
Additional context
One fix is to use the phone's perception of time to establish the start of the logging window. We currently use
datetime.now()
to get the start time prior to launching the app; we could instead useadb shell date
, and parse the result. This would ensure that the time filter passed toadb logcat
will be using a common reference time.The text was updated successfully, but these errors were encountered: