From a241c771fe0f4eda1d309c632deabd27080d65a1 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 4 Jul 2023 17:21:04 -0700 Subject: [PATCH] Upgrade to core 13.17.0 --- CHANGELOG.md | 29 +++++++++++------ Package.swift | 26 +++++++-------- .../ObjectServerTests/RLMObjectServerTests.mm | 4 +-- Realm/RLMAccessor.hpp | 2 +- Realm/RLMAccessor.mm | 4 +-- Realm/RLMError.mm | 11 ++++++- Realm/RLMObjectBase.mm | 2 +- Realm/RLMObjectStore.h | 2 +- Realm/RLMObjectStore.mm | 8 +++-- Realm/RLMSyncConfiguration.mm | 32 ++++++++++++------- build.sh | 16 ++++++++-- dependencies.list | 2 +- scripts/download-core.sh | 8 ++--- 13 files changed, 90 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 399883ebb1e..86e2cdf61c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,20 @@ x.y.z Release notes (yyyy-MM-dd) ============================================================= ### Enhancements -* None. +* Filesystem errors now include more information in the error message. +* Sync connection and session reconnect timing/backoff logic has been reworked + and unified into a single implementation. Previously some categories of errors + would cause an hour-long wait before attempting to reconnect, while others + would use an exponential backoff strategy. All errors now result in the sync + client waiting for 1 second before retrying, doubling the wait after each + subsequent failure up to a maximum of five minutes. If the cause of the error + changes, the backoff will be reset. If the sync client voluntarily disconnects, + no backoff will be used. ([Core #6526]((https://github.com/realm/realm-core/pull/6526))) ### Fixed -* ([#????](https://github.com/realm/realm-swift/issues/????), since v?.?.?) -* None. +* Fix an error during async open and client reset if properties have been added + to the schema. This fix also applies to partition-based to flexible sync + migration if async open is used. ([Core #6707](https://github.com/realm/realm-core/issues/6707), since v10.28.2) @@ -14,10 +23,16 @@ x.y.z Release notes (yyyy-MM-dd) * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.3.1. * CocoaPods: 1.10 or later. -* Xcode: 14.1-15 beta 1. +* Xcode: 14.1-15 beta 4. ### Internal -* Upgraded realm-core from ? to ? +* Upgraded realm-core from 13.15.1 to 13.17.0 +* The location where prebuilt core binaries are published has changed slightly. + If you are using `REALM_BASE_URL` to mirror the binaries, you may need to + adjust your mirroring logic. +* Release packages were being uploaded to several static.realm.io URLs which + are no longer linked to anywhere. These are no longer being updated, and + release packages are now only being uploaded to Github. 10.41.0 Release notes (2023-06-26) ============================================================= @@ -3928,10 +3943,6 @@ This release also contains all changes from 5.3.2. * Realm Studio: 10.0.0 or later. * Carthage release for Swift is built with Xcode 11.5. -### Internal -* Upgraded realm-core from ? to ? -* Upgraded realm-sync from ? to ? - 10.0.0-beta.2 Release notes (2020-06-09) ============================================================= Xcode 11.3 and iOS 9 are now the minimum supported versions. diff --git a/Package.swift b/Package.swift index 6b88afdaaed..75efaf043c5 100644 --- a/Package.swift +++ b/Package.swift @@ -1,20 +1,18 @@ -// swift-tools-version:5.5 +// swift-tools-version:5.7 import PackageDescription import Foundation -let coreVersionStr = "13.15.1" -let cocoaVersionStr = "10.41.0" +let coreVersion = Version("13.17.0") +let cocoaVersion = Version("10.41.0") -let coreVersionPieces = coreVersionStr.split(separator: ".") -let coreVersionExtra = coreVersionPieces[2].split(separator: "-") let cxxSettings: [CXXSetting] = [ .headerSearchPath("."), .headerSearchPath("include"), .define("REALM_SPM", to: "1"), .define("REALM_ENABLE_SYNC", to: "1"), - .define("REALM_COCOA_VERSION", to: "@\"\(cocoaVersionStr)\""), - .define("REALM_VERSION", to: "\"\(coreVersionStr)\""), + .define("REALM_COCOA_VERSION", to: "@\"\(cocoaVersion)\""), + .define("REALM_VERSION", to: "\"\(coreVersion)\""), .define("REALM_IOPLATFORMUUID", to: "@\"\(runCommand())\""), .define("REALM_DEBUG", .when(configuration: .debug)), @@ -23,11 +21,11 @@ let cxxSettings: [CXXSetting] = [ .define("REALM_ENABLE_ASSERTIONS", to: "1"), .define("REALM_ENABLE_ENCRYPTION", to: "1"), - .define("REALM_VERSION_MAJOR", to: String(coreVersionPieces[0])), - .define("REALM_VERSION_MINOR", to: String(coreVersionPieces[1])), - .define("REALM_VERSION_PATCH", to: String(coreVersionExtra[0])), - .define("REALM_VERSION_EXTRA", to: "\"\(coreVersionExtra.count > 1 ? String(coreVersionExtra[1]) : "")\""), - .define("REALM_VERSION_STRING", to: "\"\(coreVersionStr)\""), + .define("REALM_VERSION_MAJOR", to: String(coreVersion.major)), + .define("REALM_VERSION_MINOR", to: String(coreVersion.minor)), + .define("REALM_VERSION_PATCH", to: String(coreVersion.patch)), + .define("REALM_VERSION_EXTRA", to: "\"\(coreVersion.prereleaseIdentifiers.first ?? "")\""), + .define("REALM_VERSION_STRING", to: "\"\(coreVersion)\""), ] let testCxxSettings: [CXXSetting] = cxxSettings + [ // Command-line `swift build` resolves header search paths @@ -144,12 +142,12 @@ let package = Package( targets: ["Realm", "RealmSwift"]), ], dependencies: [ - .package(name: "RealmDatabase", url: "https://github.com/realm/realm-core.git", .exact(Version(coreVersionStr)!)) + .package(url: "https://github.com/realm/realm-core.git", exact: coreVersion) ], targets: [ .target( name: "Realm", - dependencies: [.product(name: "RealmCore", package: "RealmDatabase")], + dependencies: [.product(name: "RealmCore", package: "realm-core")], path: ".", exclude: [ "CHANGELOG.md", diff --git a/Realm/ObjectServerTests/RLMObjectServerTests.mm b/Realm/ObjectServerTests/RLMObjectServerTests.mm index 7146132164f..d13531cdfc8 100644 --- a/Realm/ObjectServerTests/RLMObjectServerTests.mm +++ b/Realm/ObjectServerTests/RLMObjectServerTests.mm @@ -1529,12 +1529,12 @@ - (void)testBeforeClientResetCallbackNotVersioned { RLMRealm *versioned = [RLMRealm realmWithConfiguration:configVersioned error:nil]; XCTAssertEqual(0U, versioned->_realm->schema_version()); } - std::shared_ptr versioned = realm::Realm::get_shared_realm(configVersioned.config); + std::shared_ptr versioned = realm::Realm::get_shared_realm(configVersioned.config)->freeze(); // Create a config that's not versioned. RLMRealmConfiguration *configUnversioned = [RLMRealmConfiguration defaultConfiguration]; configUnversioned.configRef.schema_version = RLMNotVersioned; - std::shared_ptr unversioned = realm::Realm::get_shared_realm(configUnversioned.config); + std::shared_ptr unversioned = realm::Realm::get_shared_realm(configUnversioned.config)->freeze(); XCTAssertNotEqual(versioned->schema_version(), RLMNotVersioned); XCTAssertEqual(unversioned->schema_version(), RLMNotVersioned); diff --git a/Realm/RLMAccessor.hpp b/Realm/RLMAccessor.hpp index c1d1c20d349..30d42492eb7 100644 --- a/Realm/RLMAccessor.hpp +++ b/Realm/RLMAccessor.hpp @@ -113,7 +113,7 @@ class RLMAccessorContext : public RLMStatelessAccessorContext { id box(realm::Mixed); void will_change(realm::Obj const&, realm::Property const&); - void will_change(realm::Object& obj, realm::Property const& prop) { will_change(obj.obj(), prop); } + void will_change(realm::Object& obj, realm::Property const& prop) { will_change(obj.get_obj(), prop); } void did_change(); RLMOptionalId value_for_property(id dict, realm::Property const&, size_t prop_index); diff --git a/Realm/RLMAccessor.mm b/Realm/RLMAccessor.mm index 2b98bbd2df9..db7598738e6 100644 --- a/Realm/RLMAccessor.mm +++ b/Realm/RLMAccessor.mm @@ -919,7 +919,7 @@ void RLMSetSwiftPropertyAny(__unsafe_unretained RLMObjectBase *const obj, uint16 id RLMAccessorContext::box(realm::Object&& o) { REALM_ASSERT(currentProperty); - return RLMCreateObjectAccessor(_info.linkTargetType(currentProperty.index), o.obj()); + return RLMCreateObjectAccessor(_info.linkTargetType(currentProperty.index), o.get_obj()); } id RLMAccessorContext::box(realm::Obj&& r) { @@ -1100,7 +1100,7 @@ static auto toOptional(__unsafe_unretained id const value) { try { realm::Object::create(*this, _realm->_realm, *_info.objectSchema, - (id)value, policy, existingKey, outObj).obj(); + (id)value, policy, existingKey, outObj); } catch (std::exception const& e) { @throw RLMException(e); diff --git a/Realm/RLMError.mm b/Realm/RLMError.mm index 652129f80ef..72e5ea97a3e 100644 --- a/Realm/RLMError.mm +++ b/Realm/RLMError.mm @@ -131,8 +131,17 @@ NSInteger translateFileError(realm::ErrorCodes::Error code) { || ec.category() == realm::util::error::basic_system_error_category(); NSString *errorDomain = isGenericCategoryError ? NSPOSIXErrorDomain : RLMUnknownSystemErrorDomain; + // Core v13.16 duplicates the error message in sync errors, so remove the second copy + NSString *message = @(msg); + if (auto loc = [message rangeOfString:@" (SystemError"].location; loc != NSNotFound) { + auto prefix = [message substringToIndex:loc]; + if ([message rangeOfString:prefix options:0 range:{loc, message.length - loc} locale:nil].location != NSNotFound) { + message = prefix; + } + } + NSMutableDictionary *userInfo = [NSMutableDictionary new]; - userInfo[NSLocalizedDescriptionKey] = @(msg); + userInfo[NSLocalizedDescriptionKey] = message; // FIXME: remove these in v11 userInfo[@"Error Code"] = @(code); userInfo[@"Category"] = @(ec.category().name()); diff --git a/Realm/RLMObjectBase.mm b/Realm/RLMObjectBase.mm index 02b2154c715..410a3177c35 100644 --- a/Realm/RLMObjectBase.mm +++ b/Realm/RLMObjectBase.mm @@ -440,7 +440,7 @@ + (instancetype)objectWithThreadSafeReference:(realm::ThreadSafeReference)refere return nil; } NSString *objectClassName = @(object.get_object_schema().name.c_str()); - return RLMCreateObjectAccessor(realm->_info[objectClassName], object.obj()); + return RLMCreateObjectAccessor(realm->_info[objectClassName], object.get_obj()); } @end diff --git a/Realm/RLMObjectStore.h b/Realm/RLMObjectStore.h index 69443c9659b..6045f1e8e22 100644 --- a/Realm/RLMObjectStore.h +++ b/Realm/RLMObjectStore.h @@ -92,7 +92,7 @@ RLMObjectBase *RLMObjectFromObjLink(RLMRealm *realm, // Create accessors RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, int64_t key) NS_RETURNS_RETAINED; -RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::Obj&& obj) NS_RETURNS_RETAINED; +RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, const realm::Obj& obj) NS_RETURNS_RETAINED; #endif RLM_HEADER_AUDIT_END(nullability) diff --git a/Realm/RLMObjectStore.mm b/Realm/RLMObjectStore.mm index ff87f4506ed..e648ae16a73 100644 --- a/Realm/RLMObjectStore.mm +++ b/Realm/RLMObjectStore.mm @@ -227,7 +227,7 @@ id RLMGetObject(RLMRealm *realm, NSString *objectClassName, id key) { key ?: NSNull.null); if (!obj.is_valid()) return nil; - return RLMCreateObjectAccessor(info, obj.obj()); + return RLMCreateObjectAccessor(info, obj.get_obj()); } catch (std::exception const& e) { @throw RLMException(e); @@ -239,9 +239,11 @@ id RLMGetObject(RLMRealm *realm, NSString *objectClassName, id key) { } // Create accessor and register with realm -RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::Obj&& obj) { +RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, const realm::Obj& obj) { RLMObjectBase *accessor = RLMCreateManagedAccessor(info.rlmObjectSchema.accessorClass, &info); - accessor->_row = std::move(obj); + accessor->_row = obj; RLMInitializeSwiftAccessor(accessor, false); return accessor; } +static_assert(std::is_trivially_copyable_v); +static_assert(std::is_trivially_destructible_v); diff --git a/Realm/RLMSyncConfiguration.mm b/Realm/RLMSyncConfiguration.mm index cb63e5f3bfd..a33f115f501 100644 --- a/Realm/RLMSyncConfiguration.mm +++ b/Realm/RLMSyncConfiguration.mm @@ -32,6 +32,7 @@ #import "RLMUser_Private.hpp" #import "RLMUtil.hpp" +#import #import #import #import @@ -63,9 +64,14 @@ RLMClientResetBeforeBlock block; void operator()(std::shared_ptr local) { @autoreleasepool { - if (local->schema_version() != RLMNotVersioned) { - block([RLMRealm realmWithSharedRealm:local schema:getSchema(*local) dynamic:false]); + if (local->schema_version() == RLMNotVersioned) { + return; } + if (!dynamic) { + // FIXME: core is currently giving us a realm we can't call set_schema_subscript() on. Work around this by obtaining a new one + local = realm::_impl::RealmCoordinator::get_existing_coordinator(local->config().path)->get_realm(local->config(), *local->current_transaction_version()); + } + block([RLMRealm realmWithSharedRealm:local schema:getSchema(*local) dynamic:dynamic]); } } }; @@ -74,17 +80,19 @@ void operator()(std::shared_ptr local) { RLMClientResetAfterBlock block; void operator()(std::shared_ptr local, ThreadSafeReference remote, bool) { @autoreleasepool { - if (local->schema_version() != RLMNotVersioned) { - RLMSchema *schema = getSchema(*local); - RLMRealm *localRealm = [RLMRealm realmWithSharedRealm:local - schema:schema - dynamic:false]; - - RLMRealm *remoteRealm = [RLMRealm realmWithSharedRealm:Realm::get_shared_realm(std::move(remote)) - schema:schema - dynamic:false]; - block(localRealm, remoteRealm); + if (local->schema_version() == RLMNotVersioned) { + return; } + + RLMSchema *schema = getSchema(*local); + RLMRealm *localRealm = [RLMRealm realmWithSharedRealm:local + schema:schema + dynamic:dynamic]; + + RLMRealm *remoteRealm = [RLMRealm realmWithSharedRealm:Realm::get_shared_realm(std::move(remote)) + schema:schema + dynamic:false]; + block(localRealm, remoteRealm); } } }; diff --git a/build.sh b/build.sh index 42181361fe1..277a16a81c6 100755 --- a/build.sh +++ b/build.sh @@ -914,13 +914,23 @@ case "$COMMAND" in PlistBuddy -c "Set :CFBundleShortVersionString $realm_version" "$version_file" done sed -i '' "s/^VERSION=.*/VERSION=$realm_version/" dependencies.list - sed -i '' "s/^let coreVersionStr =.*/let coreVersionStr = \"$REALM_CORE_VERSION\"/" Package.swift - sed -i '' "s/^let cocoaVersionStr =.*/let cocoaVersionStr = \"$realm_version\"/" Package.swift + sed -i '' "s/^let cocoaVersion =.*/let cocoaVersion = Version(\"$realm_version\")/" Package.swift sed -i '' "s/x.y.z Release notes (yyyy-MM-dd)/$realm_version Release notes ($(date '+%Y-%m-%d'))/" CHANGELOG.md exit 0 ;; + "set-core-version") + new_version="$2" + old_version="$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")" + + sed -i '' "s/^REALM_CORE_VERSION=.*/REALM_CORE_VERSION=$new_version/" dependencies.list + sed -i '' "s/^let coreVersion =.*/let coreVersion = Version(\"$new_version\")/" Package.swift + sed -i '' "s/Upgraded realm-core from ? to ?/Upgraded realm-core from $old_version to $new_version/" CHANGELOG.md + + exit 0 + ;; + ###################################### # Continuous Integration ###################################### @@ -1209,7 +1219,7 @@ x.y.z Release notes (yyyy-MM-dd) * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.3.1. * CocoaPods: 1.10 or later. -* Xcode: 14.1-15 beta 1. +* Xcode: 14.1-15 beta 3. ### Internal * Upgraded realm-core from ? to ? diff --git a/dependencies.list b/dependencies.list index 68d2f1fb29f..ef0b6e1d8b9 100755 --- a/dependencies.list +++ b/dependencies.list @@ -1,3 +1,3 @@ VERSION=10.41.0 -REALM_CORE_VERSION=13.15.1 +REALM_CORE_VERSION=13.17.0 STITCH_VERSION=1eb31b87154cf7af6cbe50ab2732e2856ca499c7 diff --git a/scripts/download-core.sh b/scripts/download-core.sh index 8a1b58dd1b1..514bc8de86f 100644 --- a/scripts/download-core.sh +++ b/scripts/download-core.sh @@ -5,7 +5,7 @@ source_root="$(dirname "$0")/.." readonly source_root # override this env variable if you need to download from a private mirror -: "${REALM_BASE_URL:="https://static.realm.io/downloads"}" +: "${REALM_BASE_URL:="https://static.realm.io/downloads/core"}" # set to "current" to always use the current build : "${REALM_CORE_VERSION:=$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")}" # Provide a fallback value for TMPDIR, relevant for Xcode Bots @@ -28,11 +28,7 @@ copy_core() { tries_left=3 readonly version="$REALM_CORE_VERSION" -nightly_version="" -if [[ "$REALM_CORE_VERSION" == *"nightly"* ]]; then - nightly_version="v${version}/cocoa/" -fi -readonly url="${REALM_BASE_URL}/core/${nightly_version}realm-monorepo-xcframework-v${version}.tar.xz" +readonly url="${REALM_BASE_URL}/v${version}/cocoa/realm-monorepo-xcframework-v${version}.tar.xz" # First check if we need to do anything if [ -e "$dst" ]; then if [ -e "$dst/version.txt" ]; then