Skip to content

Commit c355e21

Browse files
authored
fix: Include screenshot attachment in native backend envelope (#1624)
* fix: Include screenshot attachment in native backend envelope * Update changelog * Add scrrenshot options check * Enable native backend screenshot test * Revert test * Update skip reason comment
1 parent e12743b commit c355e21

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
- native: Fix crash daemon failing to detect crashes during OOM on Windows. ([#1603](https://github.com/getsentry/sentry-native/issues/1603))
1414
- Fix `WinHttpReceiveResponse` failures being silently ignored, which could cause envelopes to be lost instead of retried or cached. ([#1620](https://github.com/getsentry/sentry-native/pull/1620))
15+
- Fix missing screenshot attachment in native backend envelope ([#1624](https://github.com/getsentry/sentry-native/pull/1624))
1516

1617
## 0.13.4
1718

src/backends/native/sentry_crash_daemon.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,17 @@ write_envelope_with_native_stacktrace(const sentry_options_t *options,
23912391
}
23922392
}
23932393

2394+
// Add screenshot attachment if captured by the daemon
2395+
if (options && options->attach_screenshot && run_folder) {
2396+
sentry_path_t *screenshot_path
2397+
= sentry__path_join_str(run_folder, "screenshot.png");
2398+
if (screenshot_path) {
2399+
write_attachment_to_envelope(
2400+
fd, screenshot_path->path, "screenshot.png", "image/png");
2401+
sentry__path_free(screenshot_path);
2402+
}
2403+
}
2404+
23942405
#if defined(SENTRY_PLATFORM_UNIX)
23952406
close(fd);
23962407
#elif defined(SENTRY_PLATFORM_WINDOWS)
@@ -2614,6 +2625,17 @@ write_envelope_with_minidump(const sentry_options_t *options,
26142625
}
26152626
}
26162627

2628+
// Add screenshot attachment if captured by the daemon
2629+
if (options && options->attach_screenshot && run_folder) {
2630+
sentry_path_t *screenshot_path
2631+
= sentry__path_join_str(run_folder, "screenshot.png");
2632+
if (screenshot_path) {
2633+
write_attachment_to_envelope(
2634+
fd, screenshot_path->path, "screenshot.png", "image/png");
2635+
sentry__path_free(screenshot_path);
2636+
}
2637+
}
2638+
26172639
#if defined(SENTRY_PLATFORM_UNIX)
26182640
close(fd);
26192641
#elif defined(SENTRY_PLATFORM_WINDOWS)

tests/test_integration_screenshot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def assert_screenshot_upload(req):
4343
pytest.param(
4444
{"SENTRY_BACKEND": "native"},
4545
marks=pytest.mark.skip(
46-
reason="Native backend screenshot needs testing on Windows machine"
46+
reason="Native daemon cleans up run folder after processing "
47+
"so the screenshot file is no longer on disk"
4748
),
4849
),
4950
],

0 commit comments

Comments
 (0)