Skip to content

Commit

Permalink
Upgrade to latest core (#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
rorbech authored May 1, 2024
1 parent 8704401 commit 5ba0909
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 71 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ This release will bump the Realm file format from version 23 to 24. Opening a fi
* Add support for changing the App Services base URL. It allows to roam between Atlas and Edge Server. Changing the url would trigger a client reset. (Issue [#1659](https://github.com/realm/realm-kotlin/issues/1659)/[RKOTLIN-1013](https://jira.mongodb.org/browse/RKOTLIN-1023))

### Fixed
* None.
* Fixed a bug when running a IN query (or a query of the pattern `x == 1 OR x == 2 OR x == 3`) when evaluating on a string property with an empty string in the search condition. Matches with an empty string would have been evaluated as if searching for a null string instead. (Core issue [realm/realm-core#7628](https://github.com/realm/realm-core/pull/7628) since Core v10.0.0-beta.9)
* Fixed several issues around encrypted file portability (copying a "bundled" encrypted Realm from one device to another). (Core issues [realm/realm-core#7322](https://github.com/realm/realm-core/issues/7322) and [realm/realm-core#7319](https://github.com/realm/realm-core/issues/7319))
* Queries using query paths on Mixed values returns inconsistent results (Core issue [realm/realm-core#7587](https://github.com/realm/realm-core/issues/7587), since Core v14.0.0)
* [Sync] `App.allUsers()` included logged out users only if they were logged out while the App instance existed. It now always includes all logged out users. (Core issue [realm/realm-core#7300](https://github.com/realm/realm-core/pull/7300))
* [Sync] Deleting the active user left the active user unset rather than selecting another logged-in user as the active user like logging out and removing users did. (Core issue [realm/realm-core#7300](https://github.com/realm/realm-core/pull/7300))
* [Sync] Schema initialization could hit an assertion failure if the sync client applied a downloaded changeset while the Realm file was in the process of being opened (Core issue [realm/realm-core#7041](https://github.com/realm/realm-core/issues/7041), since Core v11.4.0).

### Known issues
* Missing initial download progress notification when there is no active downloads. (Issue [realm/realm-core#7627](https://github.com/realm/realm-core/issues/7627), since 1.15.1)

### Compatibility
* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
Expand All @@ -28,7 +36,7 @@ This release will bump the Realm file format from version 23 to 24. Opening a fi
* Minimum R8: 8.0.34.

### Internal
* None.
* Updated to Realm Core 14.6.1 commit cde3adb7649d3361806dbbae0cf353b8fdc4d54e.


## 1.15.0 (2024-04-17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ expect enum class ErrorCode : CodeDescription {
RLM_ERR_CUSTOM_ERROR,
RLM_ERR_CLIENT_USER_NOT_FOUND,
RLM_ERR_CLIENT_USER_NOT_LOGGED_IN,
RLM_ERR_CLIENT_APP_DEALLOCATED,
RLM_ERR_CLIENT_REDIRECT_ERROR,
RLM_ERR_CLIENT_TOO_MANY_REDIRECTS,
RLM_ERR_CLIENT_USER_ALREADY_NAMED,
RLM_ERR_BAD_TOKEN,
RLM_ERR_MALFORMED_JSON,
RLM_ERR_MISSING_JSON_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ expect object RealmInterop {
appId: String
)

fun realm_sync_client_config_set_base_file_path(
syncClientConfig: RealmSyncClientConfigurationPointer,
fun realm_app_config_set_base_file_path(
appConfig: RealmAppConfigurationPointer,
basePath: String
)

Expand All @@ -593,13 +593,13 @@ expect object RealmInterop {

fun realm_set_log_level(level: CoreLogLevel)

fun realm_sync_client_config_set_metadata_mode(
syncClientConfig: RealmSyncClientConfigurationPointer,
fun realm_app_config_set_metadata_mode(
appConfig: RealmAppConfigurationPointer,
metadataMode: MetadataMode
)

fun realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig: RealmSyncClientConfigurationPointer,
fun realm_app_config_set_metadata_encryption_key(
appConfig: RealmAppConfigurationPointer,
encryptionKey: ByteArray
)
fun realm_sync_client_config_set_user_agent_binding_info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ actual enum class ErrorCode(actual override val description: String?, actual ove
RLM_ERR_CUSTOM_ERROR("CustomError", realm_errno_e.RLM_ERR_CUSTOM_ERROR),
RLM_ERR_CLIENT_USER_NOT_FOUND("ClientUserNotFound", realm_errno_e.RLM_ERR_CLIENT_USER_NOT_FOUND),
RLM_ERR_CLIENT_USER_NOT_LOGGED_IN("ClientUserNotLoggedIn", realm_errno_e.RLM_ERR_CLIENT_USER_NOT_LOGGED_IN),
RLM_ERR_CLIENT_APP_DEALLOCATED("ClientAppDeallocated", realm_errno_e.RLM_ERR_CLIENT_APP_DEALLOCATED),
RLM_ERR_CLIENT_REDIRECT_ERROR("ClientRedirectError", realm_errno_e.RLM_ERR_CLIENT_REDIRECT_ERROR),
RLM_ERR_CLIENT_TOO_MANY_REDIRECTS("ClientTooManyRedirects", realm_errno_e.RLM_ERR_CLIENT_TOO_MANY_REDIRECTS),
RLM_ERR_CLIENT_USER_ALREADY_NAMED("ClientUserAlreadyNamed", realm_errno_e.RLM_ERR_CLIENT_USER_ALREADY_NAMED),
RLM_ERR_BAD_TOKEN("BadToken", realm_errno_e.RLM_ERR_BAD_TOKEN),
RLM_ERR_MALFORMED_JSON("MalformedJson", realm_errno_e.RLM_ERR_MALFORMED_JSON),
RLM_ERR_MISSING_JSON_KEY("MissingJsonKey", realm_errno_e.RLM_ERR_MISSING_JSON_KEY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.realm.kotlin.internal.interop

import io.realm.kotlin.internal.interop.Constants.ENCRYPTION_KEY_LENGTH
import io.realm.kotlin.internal.interop.RealmInterop.cptr
import io.realm.kotlin.internal.interop.sync.ApiKeyWrapper
import io.realm.kotlin.internal.interop.sync.AuthProvider
import io.realm.kotlin.internal.interop.sync.CoreConnectionState
Expand Down Expand Up @@ -1099,7 +1098,7 @@ actual object RealmInterop {
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String
): RealmAppPointer {
return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr(), syncClientConfig.cptr()), managed = true)
return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr()), managed = true)
}

actual fun realm_app_log_in_with_credentials(
Expand Down Expand Up @@ -1288,11 +1287,11 @@ actual object RealmInterop {
)
}

actual fun realm_sync_client_config_set_base_file_path(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_base_file_path(
appConfig: RealmAppConfigurationPointer,
basePath: String
) {
realmc.realm_sync_client_config_set_base_file_path(syncClientConfig.cptr(), basePath)
realmc.realm_app_config_set_base_file_path(appConfig.cptr(), basePath)
}

actual fun realm_sync_client_config_set_multiplex_sessions(syncClientConfig: RealmSyncClientConfigurationPointer, enabled: Boolean) {
Expand All @@ -1307,22 +1306,22 @@ actual object RealmInterop {
realmc.realm_set_log_level(level.priority)
}

actual fun realm_sync_client_config_set_metadata_mode(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_mode(
appConfig: RealmAppConfigurationPointer,
metadataMode: MetadataMode
) {
realmc.realm_sync_client_config_set_metadata_mode(
syncClientConfig.cptr(),
realmc.realm_app_config_set_metadata_mode(
appConfig.cptr(),
metadataMode.nativeValue
)
}

actual fun realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_encryption_key(
appConfig: RealmAppConfigurationPointer,
encryptionKey: ByteArray
) {
realmc.realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig.cptr(),
realmc.realm_app_config_set_metadata_encryption_key(
appConfig.cptr(),
encryptionKey
)
}
Expand Down
1 change: 1 addition & 0 deletions packages/cinterop/src/native/realm.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
headers = realm.h realm/error_codes.h
headerFilter = realm.h realm/error_codes.h
compilerOpts = -DREALM_APP_SERVICES=1
// Relative paths in def file depends are resolved differently dependent on execution
// location
// https://youtrack.jetbrains.com/issue/KT-43439
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ actual enum class ErrorCode(
RLM_ERR_CUSTOM_ERROR("CustomError", realm_errno.RLM_ERR_CUSTOM_ERROR),
RLM_ERR_CLIENT_USER_NOT_FOUND("ClientUserNotFound", realm_errno.RLM_ERR_CLIENT_USER_NOT_FOUND),
RLM_ERR_CLIENT_USER_NOT_LOGGED_IN("ClientUserNotLoggedIn", realm_errno.RLM_ERR_CLIENT_USER_NOT_LOGGED_IN),
RLM_ERR_CLIENT_APP_DEALLOCATED("ClientAppDeallocated", realm_errno.RLM_ERR_CLIENT_APP_DEALLOCATED),
RLM_ERR_CLIENT_REDIRECT_ERROR("ClientRedirectError", realm_errno.RLM_ERR_CLIENT_REDIRECT_ERROR),
RLM_ERR_CLIENT_TOO_MANY_REDIRECTS("ClientTooManyRedirects", realm_errno.RLM_ERR_CLIENT_TOO_MANY_REDIRECTS),
RLM_ERR_CLIENT_USER_ALREADY_NAMED("ClientUserAlreadyNamed", realm_errno.RLM_ERR_CLIENT_USER_ALREADY_NAMED),
RLM_ERR_BAD_TOKEN("BadToken", realm_errno.RLM_ERR_BAD_TOKEN),
RLM_ERR_MALFORMED_JSON("MalformedJson", realm_errno.RLM_ERR_MALFORMED_JSON),
RLM_ERR_MISSING_JSON_KEY("MissingJsonKey", realm_errno.RLM_ERR_MISSING_JSON_KEY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ import platform.posix.strerror
import platform.posix.uint64_t
import platform.posix.uint8_tVar
import realm_wrapper.realm_app_error_t
import realm_wrapper.realm_app_user_apikey_t
import realm_wrapper.realm_binary_t
import realm_wrapper.realm_class_info_t
import realm_wrapper.realm_class_key_tVar
Expand All @@ -123,7 +122,6 @@ import realm_wrapper.realm_results_t
import realm_wrapper.realm_scheduler_t
import realm_wrapper.realm_set_t
import realm_wrapper.realm_string_t
import realm_wrapper.realm_sync_client_metadata_mode
import realm_wrapper.realm_sync_session_resync_mode
import realm_wrapper.realm_sync_session_state_e
import realm_wrapper.realm_sync_session_stop_policy_e
Expand All @@ -134,7 +132,6 @@ import realm_wrapper.realm_sync_socket_timer_t
import realm_wrapper.realm_sync_socket_websocket_t
import realm_wrapper.realm_sync_socket_write_callback_t
import realm_wrapper.realm_t
import realm_wrapper.realm_user_identity
import realm_wrapper.realm_user_t
import realm_wrapper.realm_value_t
import realm_wrapper.realm_value_type
Expand Down Expand Up @@ -2001,7 +1998,7 @@ actual object RealmInterop {
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String
): RealmAppPointer {
return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr(), syncClientConfig.cptr()), managed = true)
return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr()), managed = true)
}

actual fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer? {
Expand Down Expand Up @@ -2068,7 +2065,7 @@ actual object RealmInterop {
app.cptr(),
user.cptr(),
name,
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_app_user_apikey_t>?, error: CPointer<realm_app_error_t>? ->
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_wrapper.realm_app_user_apikey>?, error: CPointer<realm_app_error_t>? ->
handleAppCallback(userData, error) {
apiKey!!.pointed.let {
ApiKeyWrapper(
Expand Down Expand Up @@ -2159,7 +2156,7 @@ actual object RealmInterop {
app.cptr(),
user.cptr(),
id.realm_object_id_t(),
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_app_user_apikey_t>?, error: CPointer<realm_app_error_t>? ->
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_wrapper.realm_app_user_apikey>?, error: CPointer<realm_app_error_t>? ->
handleAppCallback(userData, error) {
apiKey!!.pointed.let {
ApiKeyWrapper(
Expand Down Expand Up @@ -2188,7 +2185,7 @@ actual object RealmInterop {
realm_wrapper.realm_app_user_apikey_provider_client_fetch_apikeys(
app.cptr(),
user.cptr(),
staticCFunction { userData: CPointer<out CPointed>?, apiKeys: CPointer<realm_app_user_apikey_t>?, count: size_t, error: CPointer<realm_app_error_t>? ->
staticCFunction { userData: CPointer<out CPointed>?, apiKeys: CPointer<realm_wrapper.realm_app_user_apikey>?, count: size_t, error: CPointer<realm_app_error_t>? ->
handleAppCallback(userData, error) {
val result = arrayOfNulls<ApiKeyWrapper>(count.toInt())
for (i in 0 until count.toInt()) {
Expand Down Expand Up @@ -2339,8 +2336,8 @@ actual object RealmInterop {
actual fun realm_user_get_all_identities(user: RealmUserPointer): List<SyncUserIdentity> {
memScoped {
val count = AuthProvider.values().size
val properties = allocArray<realm_user_identity>(count)
val outCount = alloc<size_tVar>()
val properties = allocArray<realm_wrapper.realm_user_identity>(count)
val outCount: ULongVarOf<size_t> = alloc<size_tVar>()
realm_wrapper.realm_user_get_all_identities(
user.cptr(),
properties,
Expand Down Expand Up @@ -2434,11 +2431,11 @@ actual object RealmInterop {
)
}

actual fun realm_sync_client_config_set_base_file_path(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_base_file_path(
appConfig: RealmAppConfigurationPointer,
basePath: String
) {
realm_wrapper.realm_sync_client_config_set_base_file_path(syncClientConfig.cptr(), basePath)
realm_wrapper.realm_app_config_set_base_file_path(appConfig.cptr(), basePath)
}

actual fun realm_sync_client_config_set_multiplex_sessions(syncClientConfig: RealmSyncClientConfigurationPointer, enabled: Boolean) {
Expand All @@ -2460,24 +2457,24 @@ actual object RealmInterop {
realm_wrapper.realm_set_log_level(level.priority.toUInt())
}

actual fun realm_sync_client_config_set_metadata_mode(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_mode(
appConfig: RealmAppConfigurationPointer,
metadataMode: MetadataMode
) {
realm_wrapper.realm_sync_client_config_set_metadata_mode(
syncClientConfig.cptr(),
realm_sync_client_metadata_mode.byValue(metadataMode.metadataValue.toUInt())
realm_wrapper.realm_app_config_set_metadata_mode(
appConfig.cptr(),
realm_wrapper.realm_sync_client_metadata_mode.byValue(metadataMode.metadataValue.toUInt())
)
}

actual fun realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_encryption_key(
appConfig: RealmAppConfigurationPointer,
encryptionKey: ByteArray
) {
memScoped {
val encryptionKeyPointer = encryptionKey.refTo(0).getPointer(memScope)
realm_wrapper.realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig.cptr(),
realm_wrapper.realm_app_config_set_metadata_encryption_key(
appConfig.cptr(),
encryptionKeyPointer as CPointer<uint8_tVar>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/external/core
Submodule core updated 318 files
4 changes: 4 additions & 0 deletions packages/jni-swig-stub/realm.i
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%module(directors="1") realmc

#define REALM_APP_SERVICES 1

%{
#include "realm.h"
#include <cstring>
Expand Down Expand Up @@ -523,6 +525,8 @@ $result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, 2);
%ignore "realm_dictionary_add_notification_callback";
%ignore "realm_results_add_notification_callback";

%ignore "realm_app_config_get_sync_client_config";

// Swig doesn't understand __attribute__ so eliminate it
#define __attribute__(x)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
bundleId: String,
networkTransport: NetworkTransport
): RealmAppConfigurationPointer {
return RealmInterop.realm_app_config_new(
val appConfigPtr = RealmInterop.realm_app_config_new(
appId = appId,
baseUrl = baseUrl,
networkTransport = RealmInterop.realm_network_transport_new(networkTransport),
Expand All @@ -146,6 +146,15 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
frameworkVersion = RUNTIME_VERSION
)
)
RealmInterop.realm_app_config_set_base_file_path(appConfigPtr, syncRootDirectory)
RealmInterop.realm_app_config_set_metadata_mode(appConfigPtr, metadataMode)
encryptionKey?.let {
RealmInterop.realm_app_config_set_metadata_encryption_key(
appConfigPtr,
it
)
}
return appConfigPtr
}

private fun initializeSyncClientConfig(
Expand All @@ -157,21 +166,6 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
.also { syncClientConfig ->
// Initialize client configuration first
RealmInterop.realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig, appId)
RealmInterop.realm_sync_client_config_set_metadata_mode(
syncClientConfig,
metadataMode
)
RealmInterop.realm_sync_client_config_set_base_file_path(
syncClientConfig,
syncRootDirectory
)

encryptionKey?.let {
RealmInterop.realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig,
it
)
}

sdkInfo?.let {
RealmInterop.realm_sync_client_config_set_user_agent_binding_info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ internal fun convertAppError(appError: AppError): Throwable {
ErrorCode.RLM_ERR_CLIENT_USER_NOT_FOUND -> {
IllegalStateException(msg)
}
ErrorCode.RLM_ERR_CLIENT_USER_NOT_LOGGED_IN -> {
InvalidCredentialsException(msg)
}
ErrorCode.RLM_ERR_CLIENT_APP_DEALLOCATED -> {
AppException(msg)
ErrorCode.RLM_ERR_CLIENT_USER_ALREADY_NAMED -> {
CredentialsCannotBeLinkedException(msg)
}
else -> {
AppException(msg)
Expand Down
2 changes: 1 addition & 1 deletion packages/test-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ kotlin {
}
targets.filterIsInstance<KotlinNativeTargetWithSimulatorTests>().forEach { simulatorTargets ->
simulatorTargets.testRuns.forEach { testRun ->
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 12"
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 14"
}
}
sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion packages/test-sync/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ kotlin {
}
targets.filterIsInstance<KotlinNativeTargetWithSimulatorTests>().forEach { simulatorTargets ->
simulatorTargets.testRuns.forEach { testRun ->
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 12"
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 14"
}
}
sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class AppTests {
@Test
@OptIn(ExperimentalEdgeServerApi::class)
fun changeBaseUrl_invalidUrl() {
assertFailsWithMessage<IllegalArgumentException>("URL missing scheme separator") {
assertFailsWithMessage<IllegalArgumentException>("URL missing scheme") {
runBlocking {
app.updateBaseUrl("hello world")
}
Expand Down
Loading

0 comments on commit 5ba0909

Please sign in to comment.