Skip to content

Commit

Permalink
fix: linux crashpad handler path (#2443)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Nov 25, 2024
1 parent 4c13d97 commit 9e7630d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion flutter/lib/src/native/c/sentry_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:ffi';
import 'dart:io';
import 'dart:typed_data';

import 'package:collection/collection.dart';
import 'package:ffi/ffi.dart';
import 'package:meta/meta.dart';

Expand Down Expand Up @@ -31,7 +32,7 @@ class SentryNative with SentryNativeSafeInvoker implements SentryNativeBinding {
static String dynamicLibraryDirectory = '';

@visibleForTesting
static String? crashpadPath;
static String? crashpadPath = _getDefaultCrashpadPath();

SentryNative(this.options);

Expand Down Expand Up @@ -396,3 +397,19 @@ extension on List<dynamic> {
return cObject;
}
}

String? _getDefaultCrashpadPath() {
if (Platform.isLinux) {
final lastSeparator =
Platform.resolvedExecutable.lastIndexOf(Platform.pathSeparator);
if (lastSeparator >= 0) {
final appDir = Platform.resolvedExecutable.substring(0, lastSeparator);
final candidates = [
'$appDir${Platform.pathSeparator}crashpad_handler',
'$appDir${Platform.pathSeparator}bin/crashpad_handler'
];
return candidates.firstWhereOrNull((path) => File(path).existsSync());
}
}
return null;
}
2 changes: 1 addition & 1 deletion flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies:
meta: ^1.3.0
ffi: ^2.0.0
file: '>=6.1.4'
collection: ^1.16.0

dev_dependencies:
build_runner: ^2.4.2
Expand All @@ -36,7 +37,6 @@ dev_dependencies:
mockito: ^5.1.0
yaml: ^3.1.0 # needed for version match (code and pubspec)
flutter_lints: '>=4.0.0'
collection: ^1.16.0
remove_from_coverage: ^2.0.0
flutter_localizations:
sdk: flutter
Expand Down

0 comments on commit 9e7630d

Please sign in to comment.