Skip to content
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

Capture and report Thread.state for Android Runtime threads #1367

Merged
merged 3 commits into from
Sep 15, 2021

Conversation

lemnik
Copy link
Contributor

@lemnik lemnik commented Sep 13, 2021

Goal

Capture and report the Thread.state of all captured threads to help in diagnosing issues.

Design

To separate our implementation from any future platform changes or errors, a new Bugsnag Thread.State enum was introduced, reflecting the possible thread-states currently available on Android. The new enum also includes an UNKNOWN state which is used in cases where we either cannot capture or map the platform state.

Testing

Manual testing with the Example app and a debug server. Updated existing unit tests and end-to-end tests to include checks for the new Thread.State field.

@lemnik lemnik force-pushed the PLAT-7204/add-thread-state branch from 0ff0953 to 64a1aad Compare September 13, 2021 16:18
@lemnik lemnik force-pushed the PLAT-7204/add-thread-state branch from 64a1aad to 7f588ed Compare September 14, 2021 07:08
@@ -98,6 +101,7 @@ internal class ThreadSerializationTest {
"main-one",
ThreadType.ANDROID,
false,
Thread.State.RUNNABLE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to have a test case that serializes something other than RUNNABLE

@@ -32,6 +32,7 @@ public Thread deserialize(Map<String, Object> map) {
MapUtils.<String>getOrThrow(map, "name"),
ThreadType.valueOf(type.toUpperCase(Locale.US)),
errorReportingThread,
Thread.State.byName(MapUtils.<String>getOrThrow(map, "state")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this require any updates to the React Native JavaScript layer for the state field to get passed down? It feels like it might work out-of-the-box but if not then this might result in threads being dropped from JS payloads. Just something to check when updating RN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ReactNative JS layer doesn't directly know about threads, however the typescript definitions in common.d.ts will need to be changed to reflect the state property.

@@ -18,6 +19,7 @@ class ThreadInternal internal constructor(
writer.name("id").value(id)
writer.name("name").value(name)
writer.name("type").value(type.desc)
writer.name("state").value(state.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checking - will getName() be safe if ProGuard obfuscation is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Progaurd doesn't obfuscate enum names by default - but that doesn't mean other tools won't. I'll sort out something more robust 👍

@lemnik lemnik force-pushed the PLAT-7204/add-thread-state branch from f3a504b to 43654cf Compare September 14, 2021 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants