perf(flutter): Move Android JNI work to core worker to avoid work on main isolate #7967
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: flutter native & integration test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - release/** | |
| pull_request: | |
| paths: | |
| - '!**/*.md' | |
| - '!**/class-diagram.svg' | |
| - '.github/workflows/flutter_test.yml' | |
| - 'packages/dart/**' | |
| - 'packages/flutter/**' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| SENTRY_AUTH_TOKEN_E2E: ${{ secrets.SENTRY_AUTH_TOKEN_E2E }} | |
| jobs: | |
| android: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| working-directory: packages/flutter/example | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| sdk: [stable, beta] | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 | |
| with: | |
| distribution: 'adopt' | |
| java-version: '17' | |
| - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # pin@v2.21.0 | |
| with: | |
| channel: ${{ matrix.sdk }} | |
| - run: flutter pub get | |
| - name: Gradle cache | |
| uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # pin@v3.0.0 | |
| # TODO: fix emulator caching, in ubuntu-latest emulator won't boot: https://github.com/ReactiveCircus/android-emulator-runner/issues/278 | |
| - name: Launch Android emulator & run Flutter Android integration test | |
| uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a #pin@v2.37.0 | |
| with: | |
| working-directory: packages/flutter/example | |
| api-level: 31 | |
| profile: Nexus 6 | |
| arch: x86_64 | |
| force-avd-creation: false | |
| avd-name: avd-x86_64-31 | |
| emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: true | |
| script: | | |
| flutter test integration_test/all.dart --dart-define SENTRY_AUTH_TOKEN_E2E=$SENTRY_AUTH_TOKEN_E2E --verbose | |
| flutter clean | |
| flutter drive --driver=integration_test/test_driver/driver.dart --target=integration_test/sentry_widgets_flutter_binding_test.dart --profile -d emulator-5554 | |
| - name: Build APK | |
| working-directory: packages/flutter/example/android | |
| run: flutter clean && flutter build apk --debug --target-platform=android-x64 | |
| cocoa: | |
| name: '${{ matrix.target }} | ${{ matrix.sdk }}' | |
| runs-on: macos-15-xlarge | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [ios, macos] | |
| # disable beta for now as there are issues with minimum deployment version | |
| sdk: [stable] | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| # QuickFix for failing iOS 18.0 builds https://github.com/actions/runner-images/issues/12758#issuecomment-3187115656 | |
| - name: Switch to Xcode 16.4 for iOS 18.5 | |
| run: sudo xcode-select --switch /Applications/Xcode_16.4.app | |
| # Flutter derives the local SwiftPM package identity from the plugin path basename on macOS. | |
| # Our package lives in packages/flutter, which makes Xcode resolve it as "flutter" and fail with: | |
| # "unable to override package 'sentry_flutter' because its identity 'flutter' doesn't match override's identity (directory name) 'sentry_flutter'" | |
| - name: Rename sentry_flutter package for macOS SwiftPM | |
| if: matrix.target == 'macos' | |
| run: mv packages/flutter packages/sentry_flutter | |
| - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # pin@v2.21.0 | |
| with: | |
| channel: ${{ matrix.sdk }} | |
| - name: Clear SwiftPM cache | |
| run: bash ./.github/scripts/clear-swiftpm-cache.sh | |
| - run: flutter pub get | |
| working-directory: ${{ matrix.target == 'macos' && 'packages/sentry_flutter/example' || 'packages/flutter/example' }} | |
| - name: prepare test device | |
| id: device | |
| run: | | |
| case "${{ matrix.target }}" in | |
| ios) | |
| device=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-16 com.apple.CoreSimulator.SimRuntime.iOS-18-5) | |
| xcrun simctl boot ${device} | |
| echo "platform=iOS Simulator,id=${device}" >> "$GITHUB_OUTPUT" | |
| ;; | |
| macos) | |
| device="macos" | |
| echo "platform=OS X" >> "$GITHUB_OUTPUT" | |
| ;; | |
| esac | |
| echo "name=${device}" >> "$GITHUB_OUTPUT" | |
| - name: run integration test | |
| working-directory: ${{ matrix.target == 'macos' && 'packages/sentry_flutter/example' || 'packages/flutter/example' }} | |
| run: | | |
| flutter test -d "${{ steps.device.outputs.name }}" integration_test/all.dart --dart-define SENTRY_AUTH_TOKEN_E2E=$SENTRY_AUTH_TOKEN_E2E --verbose | |
| # We can only run this in macos. iOS simulator doesn't support profile mode. | |
| - name: run integration test in profile mode | |
| if: ${{ matrix.target == 'macos' }} | |
| working-directory: packages/sentry_flutter/example | |
| run: | | |
| flutter drive --driver=integration_test/test_driver/driver.dart --target=integration_test/sentry_widgets_flutter_binding_test.dart --profile -d "${{ steps.device.outputs.name }}" | |
| - name: run native test | |
| # We only have the native unit test package in the iOS xcodeproj at the moment. | |
| # Should be OK because it will likely be removed after switching to FFI (see https://github.com/getsentry/sentry-dart/issues/1444). | |
| if: ${{ matrix.target == 'ios' }} | |
| working-directory: packages/flutter/example/${{ matrix.target }} | |
| # For some reason running native unit tests directly after Flutter integration tests fails | |
| # running flutter build ios before works: https://stackoverflow.com/a/77487525/22813624 | |
| run: | | |
| flutter build ios --no-codesign | |
| xcodebuild test -workspace Runner.xcworkspace -scheme Runner -configuration Debug -destination "platform=$DEVICE_PLATFORM" -allowProvisioningUpdates CODE_SIGNING_ALLOWED=NO | |
| env: | |
| DEVICE_PLATFORM: ${{ steps.device.outputs.platform }} | |
| # TODO(buenaflor): fix the web integration test. The tests pass but the driver keeps hanging so the workflow cancels after 30minutes | |
| # web: | |
| # runs-on: ubuntu-latest | |
| # timeout-minutes: 30 | |
| # defaults: | |
| # run: | |
| # working-directory: packages/flutter/example | |
| # strategy: | |
| # fail-fast: false | |
| # matrix: | |
| # # Temporarily disable beta because the job run is flaky | |
| # sdk: ['stable'] | |
| # steps: | |
| # - name: checkout | |
| # uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| # | |
| # - name: Install Chrome Browser | |
| # uses: browser-actions/setup-chrome@b94431e051d1c52dcbe9a7092a4f10f827795416 # pin@v2.1.0 | |
| # with: | |
| # chrome-version: stable | |
| # - run: chrome --version | |
| # | |
| # - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # pin@v2.21.0 | |
| # with: | |
| # channel: ${{ matrix.sdk }} | |
| # | |
| # - name: flutter pub get | |
| # run: flutter pub get | |
| # | |
| # - name: Install Xvfb and dependencies | |
| # run: | | |
| # sudo apt-get update | |
| # sudo apt-get install -y xvfb | |
| # sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf | |
| # sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable | |
| # sudo apt-get -y install imagemagick x11-apps | |
| # | |
| # - name: Setup ChromeDriver | |
| # uses: nanasess/setup-chromedriver@e93e57b843c0c92788f22483f1a31af8ee48db25 # pin@2.3.0 | |
| # | |
| # - name: Start Xvfb and ChromeDriver and run tests | |
| # run: | | |
| # # Start Xvfb with specific screen settings | |
| # Xvfb -ac :99 -screen 0 1280x1024x16 & | |
| # export DISPLAY=:99 | |
| # | |
| # # Start ChromeDriver | |
| # chromedriver --port=4444 & | |
| # | |
| # # Wait for services to start | |
| # sleep 5 | |
| # | |
| # flutter drive \ | |
| # --driver=integration_test/test_driver/driver.dart \ | |
| # --target=integration_test/platform_integrations_test.dart \ | |
| # -d chrome | |
| # flutter drive \ | |
| # --driver=integration_test/test_driver/driver.dart \ | |
| # --target=integration_test/web_sdk_test.dart \ | |
| # -d chrome |