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

Fix excessive memory usage in the high-volume messages use case #196

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
name: swift
scm: github.com/pubnub/swift
version: "8.2.1"
version: "8.2.2"
schema: 1
changelog:
- date: 2024-12-11
version: 8.2.2
changes:
- type: bug
text: "Fix excessive memory usage in the high-volume messages use case."
- type: bug
text: "Add missing `customMessageType` in `PubNubFileEvent`."
- date: 2024-12-09
version: 8.2.1
changes:
Expand Down Expand Up @@ -624,7 +631,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub
location: https://github.com/pubnub/swift/archive/refs/tags/8.2.1.zip
location: https://github.com/pubnub/swift/archive/refs/tags/8.2.2.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down
16 changes: 8 additions & 8 deletions PubNub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3995,7 +3995,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -4046,7 +4046,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -4154,7 +4154,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -4207,7 +4207,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -4328,7 +4328,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -4380,7 +4380,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -4860,7 +4860,7 @@
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14";
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
Expand Down Expand Up @@ -4903,7 +4903,7 @@
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 8.2.1;
MARKETING_VERSION = 8.2.2;
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14";
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
Expand Down
2 changes: 1 addition & 1 deletion PubNubSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PubNubSwift'
s.version = '8.2.1'
s.version = '8.2.2'
s.homepage = 'https://github.com/pubnub/swift'
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
s.authors = { 'PubNub, Inc.' => '[email protected]' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public extension URLSessionConfiguration {
let configuration = URLSessionConfiguration.pubnub
configuration.timeoutIntervalForRequest += Constant.minimumSubscribeRequestTimeout
configuration.httpMaximumConnectionsPerHost = 1
configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
configuration.urlCache = nil

return configuration
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/PubNub/Helpers/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public enum Constant {

static let pubnubSwiftSDKName: String = "PubNubSwift"

static let pubnubSwiftSDKVersion: String = "8.2.1"
static let pubnubSwiftSDKVersion: String = "8.2.2"

static let appBundleId: String = {
if let info = Bundle.main.infoDictionary,
Expand Down
4 changes: 4 additions & 0 deletions Sources/PubNub/KMP/Wrappers/KMPFileChangeEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class KMPFileChangeEvent: NSObject {
@objc public let publisher: String?
@objc public let message: KMPAnyJSON?
@objc public let metadata: KMPAnyJSON?
@objc public let customMessageType: String?
@objc public let subscription: String?
@objc public let file: KMPFile

Expand All @@ -36,6 +37,7 @@ public class KMPFileChangeEvent: NSObject {
publisher: fileEvent.publisher,
message: fileEvent.additionalMessage?.codableValue,
metadata: fileEvent.metadata?.codableValue,
customMessageType: fileEvent.customMessageType,
subscription: fileEvent.channelGroup,
file: KMPFile(
from: fileEvent.file,
Expand All @@ -51,6 +53,7 @@ public class KMPFileChangeEvent: NSObject {
publisher: String?,
message: AnyJSON?,
metadata: AnyJSON?,
customMessageType: String?,
subscription: String?,
file: KMPFile
) {
Expand All @@ -59,6 +62,7 @@ public class KMPFileChangeEvent: NSObject {
self.publisher = publisher
self.message = if let message = message { KMPAnyJSON(message) } else { nil }
self.metadata = if let metadata = metadata { KMPAnyJSON(metadata) } else { nil }
self.customMessageType = customMessageType
self.subscription = subscription
self.file = file
}
Expand Down
26 changes: 17 additions & 9 deletions Sources/PubNub/Models/PubNubFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ public protocol PubNubFileEvent {
var additionalMessage: JSONCodable? { get }
/// Meta information for the event
var metadata: JSONCodable? { get }
/// A user-provided custom message type
var customMessageType: String? { get set }

/// Allows for converting between different `PubNubFileEvent` types
init(from other: PubNubFileEvent) throws
Expand Down Expand Up @@ -339,46 +341,50 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable {
public var channelGroup: String?
public var publisher: String
public var timetoken: Timetoken
public var customMessageType: String?

var concreteFile: PubNubFileBase
public var file: PubNubFile {
return concreteFile
concreteFile
}

var concreteAdditionalMessage: AnyJSON?
public var additionalMessage: JSONCodable? {
get {
return concreteAdditionalMessage
concreteAdditionalMessage
}
set {
concreteAdditionalMessage = newValue?.codableValue
}
}

var concreteMeta: AnyJSON?
public var metadata: JSONCodable? {
get {
return concreteMeta
concreteMeta
}
set {
concreteMeta = newValue?.codableValue
}
}

var concreteFile: PubNubFileBase
var concreteAdditionalMessage: AnyJSON?
var concreteMeta: AnyJSON?

public init(
file: PubNubFile,
channelGroup: String?,
publisher: String,
timetoken: Timetoken,
additionalMessage: JSONCodable?,
metadata: JSONCodable?
metadata: JSONCodable?,
customMessageType: String? = nil
) {
concreteFile = PubNubFileBase(from: file)
self.channelGroup = channelGroup
self.publisher = publisher
self.timetoken = timetoken
self.additionalMessage = additionalMessage
self.metadata = metadata
self.customMessageType = customMessageType
}

public init(from other: PubNubFileEvent) throws {
Expand All @@ -388,7 +394,8 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable {
publisher: other.publisher,
timetoken: other.timetoken,
additionalMessage: other.additionalMessage,
metadata: other.metadata
metadata: other.metadata,
customMessageType: other.customMessageType
)
}

Expand All @@ -414,7 +421,8 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable {
publisher: publisher,
timetoken: subscription.publishTimetoken.timetoken,
additionalMessage: filePayload.additionalDetails,
metadata: subscription.metadata
metadata: subscription.metadata,
customMessageType: subscription.customMessageType
)
}

Expand Down
Loading