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

Updated core to 13.26.0 #3502

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
* Fixed several errors that could cause a crash of the sync client. (Core 13.25.0)
* Bad performance of initial Sync download involving many backlinks. (Core 13.25.1)
* Explicitly bumped the minimum version of System.Net.Security to 4.3.2 as 4.3.0 has been marked as vulnerable (more details can be found in the deprecation notice on the [NuGet page](https://www.nuget.org/packages/System.Net.Security/4.3.0)).
* Handle EOPNOTSUPP when using posix_fallocate() and fallback to manually consume space. This should enable android users to open a Realm on restrictive filesystems. (Core 13.26.0)
* Application may crash with incoming_changesets.size() != 0 when a download message is mistaken for a bootstrap message. This can happen if the synchronization session is paused and resumed at a specific time. (Core 13.26.0)
* Fixed errors complaining about missing symbols such as `__atomic_is_lock_free` on ARMv7 Linux (Core 13.26.0)

### Compatibility
* Realm Studio: 13.0.0 or later.

### Internal
* Using Core 13.25.1.
* Using Core 13.26.0.

## 11.6.1 (2023-11-17)

Expand Down
60 changes: 39 additions & 21 deletions Realm/Realm/Handles/AppHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,17 @@ public static extern IntPtr get_user_for_testing(
[MarshalAs(UnmanagedType.LPWStr)] string access_token_buf, IntPtr access_token_len,
out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_set_fake_sync_route_for_testing", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr set_fake_sync_route_for_testing(AppHandle app, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_clear_cached_apps", CallingConvention = CallingConvention.Cdecl)]
public static extern void clear_cached_apps(out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_get_base_file_path", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr get_base_file_path(AppHandle app, IntPtr buffer, IntPtr buffer_length, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_get_base_uri", CallingConvention = CallingConvention.Cdecl)]
public static extern StringValue get_base_uri(AppHandle app, out NativeException ex);
public static extern IntPtr get_base_uri(AppHandle app, IntPtr buffer, IntPtr buffer_length, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_get_id", CallingConvention = CallingConvention.Cdecl)]
public static extern StringValue get_id(AppHandle app, out NativeException ex);
Expand Down Expand Up @@ -307,23 +310,6 @@ public async Task DeleteUserAsync(SyncUserHandle user)
}
}

public void ResetForTesting()
{
NativeMethods.reset_for_testing(this);
}

public SyncUserHandle GetUserForTesting(string id, string refreshToken, string accessToken)
{
var result = NativeMethods.get_user_for_testing(
this,
id, (IntPtr)id.Length,
refreshToken, (IntPtr)refreshToken.Length,
accessToken, (IntPtr)accessToken.Length,
out var ex);
ex.ThrowIfNecessary();
return new SyncUserHandle(result);
}

public string GetBaseFilePath()
{
return MarshalHelpers.GetString((IntPtr buffer, IntPtr length, out bool isNull, out NativeException ex) =>
Expand All @@ -335,9 +321,15 @@ public string GetBaseFilePath()

public Uri GetBaseUri()
{
var value = NativeMethods.get_base_uri(this, out var ex);
ex.ThrowIfNecessary();
return new Uri(value!);
var uriString = MarshalHelpers.GetString((IntPtr buffer, IntPtr length, out bool isNull, out NativeException ex) =>
{
isNull = false;
var value = NativeMethods.get_base_uri(this, buffer, length, out ex);
ex.ThrowIfNecessary();
return value;
papafe marked this conversation as resolved.
Show resolved Hide resolved
})!;

return new Uri(uriString);
}

public string GetId()
Expand All @@ -356,6 +348,32 @@ public bool IsSameInstance(AppHandle other)

protected override void Unbind() => NativeMethods.destroy(handle);

#region Testing
public void ResetForTesting()
{
NativeMethods.reset_for_testing(this);
}

public SyncUserHandle GetUserForTesting(string id, string refreshToken, string accessToken)
{
var result = NativeMethods.get_user_for_testing(
this,
id, (IntPtr)id.Length,
refreshToken, (IntPtr)refreshToken.Length,
accessToken, (IntPtr)accessToken.Length,
out var ex);
ex.ThrowIfNecessary();
return new SyncUserHandle(result);
}

public void SetFakeSyncRouteForTesting()
{
NativeMethods.set_fake_sync_route_for_testing(this, out var ex);
ex.ThrowIfNecessary();
}

#endregion

[MonoPInvokeCallback(typeof(NativeMethods.UserCallback))]
private static void HandleUserCallback(IntPtr tcs_ptr, IntPtr user_ptr, AppError error)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void FlexibleSync_Subscriptions_MatchesGuid([Values(true, false)] bool us
Realm.UseLegacyGuidRepresentation = useLegacyRepresentation;
#pragma warning restore CS0618 // Type or member is obsolete

var config = GetFakeFLXConfig();
var config = GetFakeFLXConfig(setFakeSyncRoute: true);
config.Schema = new[] { typeof(GuidType), typeof(EmbeddedGuidType) };
using var realm = GetRealm(config);

Expand Down Expand Up @@ -310,7 +310,7 @@ public void SynchronizedRealm_DoesntMigrate([Values(true, false)] bool useLegacy

var expected = GetGuidObjects().ToArray();

var config = GetFakeConfig(userId: "sync-guids-test-user");
var config = GetFakeConfig(userId: "sync-guids-test-user", setFakeSyncRoute: true);
config.Schema = new[] { typeof(GuidType), typeof(EmbeddedGuidType) };

TestHelpers.CopyBundledFileToDocuments("sync-guids.realm", config.DatabasePath);
Expand Down
25 changes: 23 additions & 2 deletions Tests/Realm.Tests/Sync/SyncTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
return new User(handle, app);
}

// This could be useful when opening a "fake" sync realm locally
protected void SetFakeSyncRoute(App? app)
{
app ??= DefaultApp;
app.Handle.SetFakeSyncRouteForTesting();
Comment on lines +144 to +145
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how I feel about this - I know it's just for tests, but if this is called with one of our integration apps, it would sets its sync route to a fake value, even though a real value should exist. I don't know if sync will refresh that route at some point, but I worry that as it stands, it's possible that running this test first, then running some integration tests that use the app, those will fail due to the route being misconfigured.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmmh, I understand. Good news is that all the tests are passing now, including sync tests, so I suppose it's not a problem "yet".
If we want to be more robust for the tests we could:

  • Set the fake value only if the sync route is currently empty/null
  • Set it to null/empty again at the end of the test (if modified)
  • Maybe create infrastructure in core to create those fake synced realm more "organically"?
    I am not sure if it's worth to do this though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that this is the only holdup and it's only for tests, what do you think about merging this and creating a follow up ticket so we come back to it when the core investigation is finished?

Copy link
Member

Choose a reason for hiding this comment

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

Sure

}

protected async Task<Realm> GetIntegrationRealmAsync(string? partition = null, App? app = null, int timeout = 10000)
{
var config = await GetIntegrationConfigAsync(partition, app);
Expand Down Expand Up @@ -256,15 +263,29 @@
return config;
}

protected PartitionSyncConfiguration GetFakeConfig(App? app = null, string? userId = null, string? optionalPath = null)
protected PartitionSyncConfiguration GetFakeConfig(App? app = null, string? userId = null,
string? optionalPath = null, bool setFakeSyncRoute = true)
{
var user = GetFakeUser(app, userId);

if (setFakeSyncRoute)
{
SetFakeSyncRoute(app);
}

return UpdateConfig(new PartitionSyncConfiguration(Guid.NewGuid().ToString(), user, optionalPath));
}

protected FlexibleSyncConfiguration GetFakeFLXConfig(App? app = null, string? userId = null, string? optionalPath = null)
protected FlexibleSyncConfiguration GetFakeFLXConfig(App? app = null, string? userId = null,

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win-x64

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.macOS

Code should not contain trailing whitespace [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, linux-x64

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-x64

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-arm64

Code should not contain trailing whitespace [/private/var/github/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win81

Code should not contain trailing whitespace [C:\run\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / .NET Framework

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net461]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / UWP

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.Android

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.MacCatalyst

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.MacCatalyst

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.iOS

Code should not contain trailing whitespace [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.iOS

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.iOS

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.tvOS

Code should not contain trailing whitespace [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Woven classes

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 279 in Tests/Realm.Tests/Sync/SyncTestBase.cs

View workflow job for this annotation

GitHub Actions / Test / Code Coverage

Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]
papafe marked this conversation as resolved.
Show resolved Hide resolved
string? optionalPath = null, bool setFakeSyncRoute = true)
{
var user = GetFakeUser(app, userId);

if (setFakeSyncRoute)
{
SetFakeSyncRoute(app);
}

return UpdateConfig(new FlexibleSyncConfiguration(user, optionalPath));
}

Expand Down
2 changes: 1 addition & 1 deletion wrappers/realm-core
Submodule realm-core updated 79 files
+29 −0 CHANGELOG.md
+17 −33 Jenkinsfile
+2 −1 Package.swift
+9 −3 bindgen/spec.yml
+4 −2 dependencies.list
+17 −8 evergreen/config.yml
+48 −2 evergreen/install_baas.sh
+2 −0 evergreen/setup_baas_host_local.sh
+8 −14 how-to-build.md
+30 −0 src/realm.h
+4 −0 src/realm/CMakeLists.txt
+6 −16 src/realm/db.cpp
+2 −3 src/realm/db.hpp
+1 −0 src/realm/error_codes.cpp
+3 −0 src/realm/error_codes.h
+1 −0 src/realm/error_codes.hpp
+1 −0 src/realm/exceptions.cpp
+22 −0 src/realm/exceptions.hpp
+9 −5 src/realm/object-store/audit.mm
+22 −2 src/realm/object-store/c_api/app.cpp
+4 −3 src/realm/object-store/impl/realm_coordinator.cpp
+5 −2 src/realm/object-store/impl/realm_coordinator.hpp
+5 −4 src/realm/object-store/object_store.cpp
+2 −1 src/realm/object-store/object_store.hpp
+24 −8 src/realm/object-store/shared_realm.cpp
+7 −10 src/realm/object-store/shared_realm.hpp
+345 −244 src/realm/object-store/sync/app.cpp
+140 −71 src/realm/object-store/sync/app.hpp
+107 −8 src/realm/object-store/sync/app_utils.cpp
+19 −2 src/realm/object-store/sync/app_utils.hpp
+119 −19 src/realm/object-store/sync/async_open_task.cpp
+14 −4 src/realm/object-store/sync/async_open_task.hpp
+3 −1 src/realm/object-store/sync/generic_network_transport.cpp
+6 −0 src/realm/object-store/sync/impl/sync_client.hpp
+5 −4 src/realm/object-store/sync/sync_manager.cpp
+13 −3 src/realm/object-store/sync/sync_manager.hpp
+101 −14 src/realm/object-store/sync/sync_session.cpp
+22 −11 src/realm/object-store/sync/sync_session.hpp
+2 −2 src/realm/object-store/sync/sync_user.cpp
+6 −4 src/realm/object-store/sync/sync_user.hpp
+2 −0 src/realm/sync/CMakeLists.txt
+39 −4 src/realm/sync/client.cpp
+8 −18 src/realm/sync/client.hpp
+9 −0 src/realm/sync/network/http.cpp
+40 −3 src/realm/sync/network/http.hpp
+19 −4 src/realm/sync/noinst/client_impl_base.cpp
+5 −0 src/realm/sync/noinst/client_impl_base.hpp
+2 −10 src/realm/sync/noinst/migration_store.cpp
+3 −2 src/realm/sync/noinst/migration_store.hpp
+11 −0 src/realm/sync/noinst/protocol_codec.hpp
+109 −0 src/realm/sync/noinst/sync_schema_migration.cpp
+33 −0 src/realm/sync/noinst/sync_schema_migration.hpp
+9 −0 src/realm/sync/protocol.cpp
+16 −4 src/realm/sync/protocol.hpp
+2 −12 src/realm/sync/subscriptions.cpp
+3 −3 src/realm/sync/subscriptions.hpp
+1 −1 src/realm/util/file.cpp
+1 −0 test/object-store/CMakeLists.txt
+69 −9 test/object-store/c_api/c_api.cpp
+0 −6 test/object-store/realm.cpp
+953 −209 test/object-store/sync/app.cpp
+6 −0 test/object-store/sync/flx_migration.cpp
+990 −0 test/object-store/sync/flx_schema_migration.cpp
+40 −3 test/object-store/sync/flx_sync.cpp
+23 −0 test/object-store/sync/session/session.cpp
+95 −40 test/object-store/util/sync/baas_admin_api.cpp
+2 −0 test/object-store/util/sync/baas_admin_api.hpp
+9 −3 test/object-store/util/sync/flx_sync_harness.hpp
+11 −2 test/object-store/util/sync/sync_test_utils.cpp
+2 −0 test/object-store/util/sync/sync_test_utils.hpp
+5 −5 test/object-store/util/test_file.cpp
+1 −1 test/object-store/util/test_file.hpp
+13 −0 test/object-store/util/test_utils.hpp
+10 −4 test/object-store/util/unit_test_transport.cpp
+13 −0 test/object-store/util/unit_test_transport.hpp
+28 −13 test/test_lang_bind_helper.cpp
+135 −0 test/test_util_http.cpp
+10 −4 tools/cmake/GetVersion.cmake
+0 −5 tools/run_baas_docker_image.sh
21 changes: 16 additions & 5 deletions wrappers/src/app_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ extern "C" {
sync_client_config.custom_encryption_key = std::vector<char>(key.begin(), key.end());
}

SharedApp app = app_config.use_cache
? App::get_shared_app(std::move(config), std::move(sync_client_config))
: App::get_uncached_app(std::move(config), std::move(sync_client_config));
SharedApp app = App::get_app(app_config.use_cache ?
realm::app::App::CacheMode::Enabled : realm::app::App::CacheMode::Disabled,
std::move(config),
std::move(sync_client_config));

return new SharedApp(app);
});
Expand Down Expand Up @@ -250,6 +251,15 @@ extern "C" {
});
}

REALM_EXPORT void shared_app_set_fake_sync_route_for_testing(SharedApp& app,
NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
app->sync_manager()->set_sync_route("realm://www.test.com:1000");
});
}


REALM_EXPORT void shared_app_remove_user(SharedApp& app, SharedSyncUser& user, void* tcs_ptr, NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
Expand Down Expand Up @@ -318,10 +328,11 @@ extern "C" {
});
}

REALM_EXPORT realm_string_t shared_app_get_base_uri(SharedApp& app, NativeException::Marshallable& ex)
REALM_EXPORT size_t shared_app_get_base_uri(SharedApp& app, uint16_t* buffer, size_t buffer_length, NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
return to_capi(app->base_url());
std::string url(app->get_base_url());
return stringdata_to_csharpstringbuffer(url, buffer, buffer_length);
});
}

Expand Down
Loading