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

Cross-Plattform Crash Reporting #4455

Merged
merged 28 commits into from
Nov 23, 2022
Merged

Cross-Plattform Crash Reporting #4455

merged 28 commits into from
Nov 23, 2022

Conversation

strseb
Copy link
Collaborator

@strseb strseb commented Sep 14, 2022

Description

This PR adds experimental crash reporting support using sentry-native.
The feature is disabled by default, only enabled when we're on guardian-stage.

By Crossplattform, i mean osx and windows for now :) - Linux should be straightforward to add, i don't have a vm to test that on right now.

Android & iOS are theoretically supported. We need to either figurre out how to get this into the qmake structure, or port those plattforms finally to cmake again like (#4301)

##Ref
https://mozilla-hub.atlassian.net/browse/VPN-2822

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question) -> I DID.
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed

@strseb strseb requested a review from bakulf September 14, 2022 18:15
@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2022

Codecov Report

Base: 37.23% // Head: 35.50% // Decreases project coverage by -1.72% ⚠️

Coverage data is based on head (21664db) compared to base (46f177c).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4455      +/-   ##
==========================================
- Coverage   37.23%   35.50%   -1.73%     
==========================================
  Files         325      328       +3     
  Lines       21699    22038     +339     
  Branches    11739    11832      +93     
==========================================
- Hits         8079     7825     -254     
- Misses       6080     6778     +698     
+ Partials     7540     7435     -105     
Flag Coverage Δ
functional_tests 22.32% <0.00%> (-5.12%) ⬇️
lottie_tests 23.06% <ø> (ø)
unit_tests 34.14% <0.00%> (+0.68%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/commands/commandui.cpp 38.61% <ø> (-1.39%) ⬇️
src/constants.h 20.00% <ø> (-2.23%) ⬇️
src/featureslist.h 0.00% <0.00%> (ø)
src/mozillavpn.cpp 23.58% <0.00%> (-0.65%) ⬇️
src/networkrequest.cpp 17.91% <0.00%> (-0.85%) ⬇️
src/networkrequest.h 0.00% <ø> (-50.00%) ⬇️
src/tasks/sentry/tasksentry.cpp 0.00% <0.00%> (ø)
src/tasks/addonindex/taskaddonindex.h 0.00% <0.00%> (-100.00%) ⬇️
src/captiveportal/captiveportalrequest.h 0.00% <0.00%> (-100.00%) ⬇️
src/tasks/removedevice/taskremovedevice.h 0.00% <0.00%> (-100.00%) ⬇️
... and 113 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

LICENSE.md Show resolved Hide resolved
src/cmake/sentry.cmake Outdated Show resolved Hide resolved


# Defines which OS builds can include sentry. Check src/cmake Lists for all values of MVPN_PLATFORM_NAME
set(SENTRY_SUPPORTED_OS "windows" "macos")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why only these 2 platforms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding it is trivial, but i assume that I cannot use the ExernalProject with the PPA builds, as that would need to be present in the source bundle thing?

src/qmake/sources.pri Outdated Show resolved Hide resolved
src/qmake/sources.pri Outdated Show resolved Hide resolved
auto appLocal = appDatas.first() + "\\sentry";
sentry_options_set_dsn(options, Constants::SENTRY_DER);
sentry_options_set_environment(
options, Constants::inProduction() ? "production" : "stage");
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are in prod. See the if-stmt at the top

src/sentry/sentryadapter.cpp Outdated Show resolved Hide resolved
src/sentry/sentryadapter.h Outdated Show resolved Hide resolved
src/sentry/sentryadapter.h Outdated Show resolved Hide resolved
// -> Maybe start a new Process for the Crash-Report UI ask for consent
// -> Check if a setting "upload crashes" is present.
// If we should not send it, we can discard the crash data here :)
if (shouldSend) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check with legal if we can use the telemetry policy flag.

@strseb strseb requested review from bakulf and brizental November 16, 2022 17:34
# this is super easy to link against and we do not need another binary shipped with the client.
SET(SENTRY_ARGS -DSENTRY_BACKEND=breakpad -DSENTRY_BUILD_SHARED_LIBS=false -DSENTRY_TRANSPORT=none)
endif()
if(WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we use an elseif here? Also for the Android conditional.



# Defines which OS builds can include sentry. Check src/cmake Lists for all values of MVPN_PLATFORM_NAME
set(SENTRY_SUPPORTED_OS "Windows" "Darwin" "Android")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why no iOS and Linux?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not tested so far, as i don't have a build machine setuped yet 😅.
For iOS I want to wait for it to be moved to cmake before i start that.

Copy link
Contributor

@brizental brizental Nov 17, 2022

Choose a reason for hiding this comment

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

Heh, totally get that. Let's file tickets for the iOS and Linux work though, so we can keep track of it.

else()
# Sentry is not supported on this Plattform.
message("Sentry supported OS -> ${SENTRY_SUPPORTED_OS}")
message("Cannot build sentry for ${CMAKE_SYSTEM_NAME}")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd remove this message. It's redudant with the previous one and it looks like an error.

target_sources(mozillavpn PRIVATE
tasks/sentry/tasksentry.cpp
tasks/sentry/tasksentry.h
)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: newline.

@@ -179,9 +178,6 @@ int CommandUI::run(QStringList& tokens) {
std::cerr.clear();
}
# endif

CrashClient::instance().start(CommandLineParser::argc(),
CommandLineParser::argv());
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: What are we removing here? What is the crash client? How is this related to the Sentry changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The crash client is a mini qt application we're shipping in the client. It shows the "ohno it's crashed, wanna upload?" prompt. It's currently only running under windows.
This line will make the crash client register itself for "structured exception handling", - which we don't want as sentry will do that.
On that note, I currently don't want to rip that whole thing out.... yet. We might still want to create the crash-ui process, in the sentry onCrash handler.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, yeah my question was a precursor to me asking if you wanted to also just remove the whole thing. Thanks for clarifying!

* argument to this function.
* The transport takes ownership of the `envelope`, and must free it once it
* is done.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this also a doxygen style comment?

// Will be used if NONE_TRANSPORT is enabled
// in that case this will be called if the client has a
// report to send to Sentry.
static void transportEnvelope(sentry_envelope_t* envelope, void* state);
Copy link
Contributor

Choose a reason for hiding this comment

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

Love the comment adding on this file. In mozilla-central docstrings are added to the header files too, right? I've been adding them to the .cpp file, maybe we should reach an agreement about this, happy to swich from .cpp to .h. On another note, I believe ideally we should use doxygen format comments, just because if we ever decide to auto generate docs based on these doc-comments it will be easier that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mc has most in the header; Which i kind of like because I can easily can get a glimpse of what everything in the class is happening. :D
Totally with you about the standard comment, I already forgot that we agreed on a standard format :D

Copy link
Contributor

Choose a reason for hiding this comment

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

LOL, well me and you agreed. We should probably broadcast that. I agree with having it in the header. I'll do that from now on and also change the stuff that is not in the header!

Copy link
Contributor

Choose a reason for hiding this comment

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

File looks beautiful now with all the comments 💯

logger.debug() << "Sentry sent events";
emit completed();
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: newline.

QByteArray m_envelope;
};

#endif // TASKSENTRY_H
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: newline.

taskcluster/scripts/fetch/enter_dev_shell.ps1 Show resolved Hide resolved
@strseb strseb requested a review from brizental November 17, 2022 12:58
Copy link
Contributor

@brizental brizental left a comment

Choose a reason for hiding this comment

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

LGTM. Left some minor stuff. This is a great change, excited for those sentry reports!

"Sentry Crash Report SDK", // Feature name
"2.13.0", // released
FeatureCallback_false, // Can be flipped on
FeatureCallback_false, // Can be flipped off
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not allow flipping it on and off?

/**
* @brief Inits Sentry.
*
* This is a no-op if the client is in production mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "This is a no-op if the "sentry" feature is turned off".

This way if we change the feature we don't need to update this again :)

src/featureslist.h Show resolved Hide resolved
@strseb strseb merged commit 65f10b6 into main Nov 23, 2022
@strseb strseb deleted the sentry branch November 23, 2022 14:18
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.

4 participants