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

Support stopSession() and resumeSession() in NDK #432

Merged
merged 5 commits into from
Feb 18, 2019

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Feb 14, 2019

Goal

Adds the ability to stop and resume sessions in the NDK layer. When a session is stopped, session information will not be added to error payloads and handled/unhandled error counts will not be incremented.

For fatal NDK errors, we cannot call the JNI without crashing the process, so we write an error report to disk using C. This PR updates the serialisation code to handle the concept of a stopped session.

See #429 for the Java implementation, and further details.

Changeset

  • Emit a SESSION_STARTED observable event from SessionTracker.java when a session is started or resumed, which ultimately sets session information on the NDK payload.
  • Add a SESSION_STOPPED observable event, which sets a boolean flag on bugsnag_report that prevents serialisation of session information in fatal NDK error reports
  • Update the SESSION_STARTED event to also include the handled count, rather than assuming it will always equal 0.

Tests

Added mazerunner scenarios to verify that session information is not present in error payloads of a stopped session.

Allow sessions to be stopped on the NDK. when a session is stopped from the java layer, the session
information will no longer be serialised in the error payload of fatal NDK errors.
the START_SESSION message is emitted when a session is started or resumed, and allows the NDK layer
to update its cached value for session information which is included in the error payload. It was
previously assumed that the handled count would always be 0 when starting a session - this is no
longer the case as sessions can be resumed, therefore the handled count is passed as part of the
message.
Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

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

Looks good, added two small improvements.

}

void stopSession() {
Session session = currentSession.get();

if (session != null) {
session.isStopped.set(true);
setChanged();
notifyObservers(new NativeInterface.Message(
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be an ObserverInterfaceTest covering STOP_SESSION events.

@@ -326,6 +334,10 @@ private void handleStartSession(Object arg) {
warn("START_SESSION object is invalid: " + arg);
}

private void handleStopSession() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method, while consistent with many of the others, is redundant. Could instead just call stoppedSession() above, similar to clearBreadcrumbs() and addHandledEvent(), which also don't need additional processing before crossing to the native layer.

@fractalwrench fractalwrench merged commit d8eb89d into stop-sessions Feb 18, 2019
@fractalwrench fractalwrench deleted the stop-sessions-ndk branch February 18, 2019 13:32
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