Skip to content

Commit

Permalink
Failed to load dynamic library (#1143)
Browse files Browse the repository at this point in the history
Downgrade Ubuntu build OS and add tests on ubuntu 20.04 and 22.04
- Fixes #1141 
- Fixes #1017
  • Loading branch information
desistefanova authored Feb 7, 2023
1 parent 5ddd1b9 commit cb8149d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
build-native:
runs-on: ${{ inputs.runner }}-latest
runs-on: ${{ inputs.runner }}
name: Build native
timeout-minutes: 60
strategy:
Expand All @@ -37,7 +37,7 @@ jobs:
uses: actions/cache@v3
with:
path: ./binary/**
key: binaries-${{ matrix.build }}-${{hashFiles('./src/**')}}
key: binaries-${{ matrix.build }}-{{ inputs.runner }}-${{hashFiles('./src/**')}}

- name: Setup Ninja
if: contains(github.head_ref, 'release/') || steps.check-cache.outputs.cache-hit != 'true'
Expand Down
51 changes: 46 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ jobs:
- dart-tests-macos
- dart-tests-macos-arm
- dart-tests-linux
- dart-tests-linux-ubuntu-20
- flutter-desktop-tests-windows
- flutter-desktop-tests-macos
- flutter-desktop-tests-linux
- flutter-desktop-tests-linux-ubuntu-20
- flutter-ios
- flutter-android
steps:
Expand All @@ -70,9 +72,11 @@ jobs:
- dart-tests-macos
- dart-tests-macos-arm
- dart-tests-linux
- dart-tests-linux-ubuntu-20
- flutter-desktop-tests-windows
- flutter-desktop-tests-macos
- flutter-desktop-tests-linux
- flutter-desktop-tests-linux-ubuntu-20
- flutter-ios
- flutter-android
strategy:
Expand All @@ -85,12 +89,16 @@ jobs:
description: dart macos-arm
- app: dl
description: dart linux
- app: dl2
description: dart linux (ubuntu 20)
- app: dw
description: dart windows
- app: fm
description: flutter macos
- app: fl
description: flutter linux
- app: fl2
description: flutter linux (ubuntu 20)
- app: fw
description: flutter windows
- app: fa
Expand Down Expand Up @@ -129,39 +137,39 @@ jobs:
name: Build Windows
uses: ./.github/workflows/build-native.yml
with:
runner: windows
runner: windows-latest
binary: windows
build: '["windows"]'

build-macos:
name: Build MacOS
uses: ./.github/workflows/build-native.yml
with:
runner: macos
runner: macos-latest
binary: macos
build: '["macos"]'

build-linux:
name: Build Linux
uses: ./.github/workflows/build-native.yml
with:
runner: ubuntu
runner: ubuntu-20.04 # Building on the lowest possible Linux (Ubuntu) version for compatibility
binary: linux
build: '["linux"]'

build-android:
name: Build Android
uses: ./.github/workflows/build-native.yml
with:
runner: ubuntu
runner: ubuntu-20.04
binary: android
build: '["android-x86", "android-x86_64", "android-armeabi-v7a", "android-arm64-v8a"]'

build-ios:
name: Build IOS
uses: ./.github/workflows/build-native.yml
with:
runner: macos
runner: macos-latest
binary: ios
build: '["ios-device", "ios-simulator", "ios-catalyst"]'

Expand All @@ -186,6 +194,7 @@ jobs:
secrets: inherit
with:
os: windows
runner: windows-latest
app: dw
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

Expand All @@ -198,6 +207,7 @@ jobs:
secrets: inherit
with:
os: macos
runner: macos-latest
app: dm
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

Expand All @@ -210,6 +220,7 @@ jobs:
secrets: inherit
with:
os: macos
runner: macos-arm
architecture: arm
app: dma
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}
Expand All @@ -223,9 +234,23 @@ jobs:
secrets: inherit
with:
os: linux
runner: ubuntu-latest
app: dl
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

dart-tests-linux-ubuntu-20:
name: Linux Dart Tests (ubuntu 20)
uses: ./.github/workflows/dart-desktop-tests.yml
needs:
- build-linux
- deploy-cluster
secrets: inherit
with:
os: linux
runner: ubuntu-20.04
app: dl2
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

# Flutter jobs

flutter-desktop-tests-windows:
Expand All @@ -237,6 +262,7 @@ jobs:
secrets: inherit
with:
os: windows
runner: windows-latest
app: fw
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

Expand All @@ -249,6 +275,7 @@ jobs:
secrets: inherit
with:
os: macos
runner: macos-latest
app: fm
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

Expand All @@ -261,9 +288,23 @@ jobs:
secrets: inherit
with:
os: linux
runner: ubuntu-latest
app: fl
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

flutter-desktop-tests-linux-ubuntu-20:
name: Linux Flutter Tests (ubuntu 20)
uses: ./.github/workflows/flutter-desktop-tests.yml
needs:
- build-linux
- deploy-cluster
secrets: inherit
with:
os: linux
runner: ubuntu-20.04
app: fl2
cluster: ${{ needs.deploy-cluster.outputs.clusterName }}

flutter-ios:
runs-on: macos-latest
name: IOS Flutter Tests
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart-desktop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: OS to execute on.
required: true
type: string
runner:
description: GitHub runnar image to execute on.
required: true
type: string
architecture:
description: Architecture to execute on.
required: false
Expand All @@ -29,7 +33,7 @@ env:

jobs:
dart-tests:
runs-on: ${{ inputs.os == 'linux' && 'ubuntu' || inputs.os }}-${{ inputs.architecture || 'latest' }}
runs-on: ${{ inputs.runner }}
name: Dart tests on ${{inputs.os }} ${{ inputs.architecture }}
timeout-minutes: 45
env:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/flutter-desktop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: OS to execute on.
required: true
type: string
runner:
description: GitHub runner image to execute on.
required: true
type: string
architecture:
description: Architecture to execute on.
required: false
Expand All @@ -29,7 +33,7 @@ env:

jobs:
flutter-tests:
runs-on: ${{ inputs.os == 'linux' && 'ubuntu' || inputs.os }}-${{ inputs.architecture || 'latest' }}
runs-on: ${{ inputs.runner }}
name: Flutter tests on ${{inputs.os }}-${{ inputs.architecture }}
timeout-minutes: 45
env:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**This project is in Release Candidate stage.**

### Enhancements
* None
* Improved error information returned when the `realm_dart` library failed to load. ([#1143](https://github.com/realm/realm-dart/pull/1143))

### Fixed
* Improve performance of interprocess mutexes on iOS which don’t need to support reader-writer locking. The primary beneficiary of this is beginning and ending read transactions, which is now almost as fast as pre-v13.0.0 (Core upgrade).
Expand Down
7 changes: 4 additions & 3 deletions lib/src/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ffi';
import 'dart:io';

import 'package:path/path.dart' as p;
import 'package:realm_common/realm_common.dart';

import '../realm.dart' as realm show isFlutterPlatform;
import '../realm.dart' show realmBinaryName;
Expand Down Expand Up @@ -65,7 +66,7 @@ DynamicLibrary _openRealmLib() {
final root = _getNearestProjectRoot(Platform.script.path) ?? _getNearestProjectRoot(p.current);

// Try to open lib from various candidate paths
Error? ex;
List<String> errMessages = [];
for (final open in [
() => _open(libName), // just ask OS..
() => _open(p.join(_exeDirName, libName)), // try finding it next to the executable
Expand All @@ -75,10 +76,10 @@ DynamicLibrary _openRealmLib() {
try {
return open();
} on Error catch (e) {
ex ??= e; // remember first exception, if everything fails
errMessages.add(e.toString());
}
}
throw ex!; // rethrow first
throw RealmError(errMessages.join('\n'));
}

DynamicLibrary _open(String lib) => DynamicLibrary.open(lib);
Expand Down

0 comments on commit cb8149d

Please sign in to comment.