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

[feature/reduce-mem-footprint] Reduce memory footprint #1376

Merged
merged 23 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6fffa57
- update SDK
felix-schwarz Apr 29, 2024
ffbb8f2
- update SDK and adapt to API changes
felix-schwarz Jun 13, 2024
cd17388
- update SDK to improve TUS upload reliability / error/termination re…
felix-schwarz Jun 13, 2024
be3782d
- update SDK to include TUS progress reporting and fix "UNKNOWN TASK"…
felix-schwarz Jun 27, 2024
5077254
- update SDK reference after rebase
felix-schwarz Jun 27, 2024
b606c65
- update SDK to auto-restart stuck Sync Actions
felix-schwarz Jul 5, 2024
57b5ae8
- ios-sdk: update SDK to include the latest fixes
felix-schwarz Jul 16, 2024
808fb98
- update SDK to gain flow control for Item Policy Processors
felix-schwarz Jul 25, 2024
1bfec59
- update SDK reference to include latest feature/policy-upgrades
felix-schwarz Jul 30, 2024
7837e1b
- update SDK commit reference
felix-schwarz Jul 30, 2024
291ae67
- fix Xcode 16 build error by upgrading OpenSSL from 3.1.5001 to 3.1.…
felix-schwarz Aug 13, 2024
d5e0c3d
- update LastUpgradeCheck from Xcode 14.2 to Xcode 16
felix-schwarz Aug 14, 2024
3c055f6
- Reduce memory footprint of File Provider by removing ownCloudApp.fr…
felix-schwarz Aug 20, 2024
4e109a5
- update ios-sdk
felix-schwarz Aug 27, 2024
ed38ee0
- update SDK to incorporate fix
felix-schwarz Aug 27, 2024
2ba3eee
- SDK update to reduce memory footprint further
felix-schwarz Aug 27, 2024
ec44666
- SDK update (with fixes)
felix-schwarz Aug 28, 2024
74be5b5
- File Provider Extension: add code that handles iOS 18 requests for …
felix-schwarz Sep 2, 2024
919eef4
- ShareExtensionViewController:
felix-schwarz Sep 5, 2024
5fcd9b8
- SaveFileIntentHandler: no longer use File Provider for uploading
felix-schwarz Sep 9, 2024
f5de610
- update SDK
felix-schwarz Sep 9, 2024
618dc8f
updated to merged SDK commit
hosy Sep 11, 2024
6f7ba0c
updated to latest SDK master commit
hosy Sep 11, 2024
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
2 changes: 1 addition & 1 deletion ios-sdk
Submodule ios-sdk updated 144 files
6 changes: 5 additions & 1 deletion ownCloud File Provider/FileProviderContentEnumerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
*
*/

#import <ownCloudApp/ownCloudApp.h>
#import <ownCloudSDK/ownCloudSDK.h>

// BEGIN: Shared with ownCloudApp.framework
#import "DisplaySettings.h"
// END: shared with ownCloudApp.framework

#import "FileProviderContentEnumerator.h"
#import "FileProviderEnumeratorObserver.h"
Expand Down
1 change: 0 additions & 1 deletion ownCloud File Provider/FileProviderExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

extern OCClaimExplicitIdentifier OCClaimExplicitIdentifierFileProvider;

extern OCClassSettingsIdentifier OCClassSettingsIdentifierFileProvider;
extern OCClassSettingsKey OCClassSettingsKeyFileProviderSkipLocalErrorChecks;

#define FPLogCmdBegin(command, format,...) \
Expand Down
26 changes: 23 additions & 3 deletions ownCloud File Provider/FileProviderExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@
*/

#import <ownCloudSDK/ownCloudSDK.h>
#import <ownCloudApp/ownCloudApp.h>

// BEGIN: Shared with ownCloudApp.framework
#import "Branding.h"
#import "BrandingClassSettingsSource.h"
#import "NotificationManager.h"
#import "NotificationMessagePresenter.h"
#import "NotificationAuthErrorForwarder.h"
#import "OCBookmark+AppExtensions.h"
#import "OCBookmark+FPServices.h"
#import "OCCore+BundleImport.h"
#import "OCFileProviderSettings.h"
#import "VFSManager.h"
#import "AppLockSettings.h"
#import "ZIPArchive.h"
// END: shared with ownCloudApp.framework

#import "FileProviderExtension.h"
#import "OCItem+FileProviderItem.h"
Expand Down Expand Up @@ -362,6 +376,12 @@ - (void)startProvidingItemAtURL:(NSURL *)provideAtURL completionHandler:(void (^
{
FPLogCmdBegin(@"StartProviding", @"Downloading %@", item);

if (((OCItem *)item).type == OCItemTypeCollection) {
// Can't download folders
completionHandler([NSError errorWithDomain:NSCocoaErrorDomain code:NSFeatureUnsupportedError userInfo:@{}]);
return;
}

[self.core downloadItem:(OCItem *)item options:@{

OCCoreOptionAddFileClaim : [OCClaim claimForLifetimeOfCore:core explicitIdentifier:OCClaimExplicitIdentifierFileProvider withLockType:OCClaimLockTypeRead]
Expand Down Expand Up @@ -487,7 +507,7 @@ - (void)stopProvidingItemAtURL:(NSURL *)url
// Cancel download if the item is currently downloading
if (item.isDownloading)
{
if ((downloadProgress = [self.core progressForItem:(OCItem *)item matchingEventType:OCEventTypeDownload]) != nil)
if ((downloadProgress = [self.core progressForItemWithLocalID:((OCItem *)item).localID matchingEventType:OCEventTypeDownload]) != nil)
{
[downloadProgress makeObjectsPerformSelector:@selector(cancel)];
}
Expand Down Expand Up @@ -786,6 +806,7 @@ - (void)importDocumentAtURL:(NSURL *)fileURL toParentItemIdentifier:(NSFileProvi
OCCoreOptionImportByCopying : @(importByCopying)
} placeholderCompletionHandler:^(NSError *error, OCItem *item) {
FPLogCmd(@"Completed with placeholderItem=%@, error=%@", item, error);
item.bookmarkUUID = self.core.bookmark.uuid.UUIDString; // ensure bookmarkUUID is present so that vfsItemID / itemIdentifier succeed
completionHandler(item, [error translatedError]);
} resultHandler:^(NSError *error, OCCore *core, OCItem *item, id parameter) {
if ([error.domain isEqual:OCHTTPStatusErrorDomain] && (error.code == OCHTTPStatusCodePRECONDITION_FAILED))
Expand Down Expand Up @@ -1382,7 +1403,6 @@ - (BOOL)skipLocalErrorChecks
@end

OCClaimExplicitIdentifier OCClaimExplicitIdentifierFileProvider = @"fileProvider";
OCClassSettingsIdentifier OCClassSettingsIdentifierFileProvider = @"file-provider";
OCClassSettingsKey OCClassSettingsKeyFileProviderSkipLocalErrorChecks = @"skip-local-error-checks";

/*
Expand Down
7 changes: 6 additions & 1 deletion ownCloud File Provider/FileProviderServiceSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
*/

#import "FileProviderServiceSource.h"
#import <ownCloudApp/ownCloudApp.h>

// BEGIN: Shared with ownCloudApp.framework
#import "OCFileProviderService.h"
#import "OCCore+BundleImport.h"
// END: Shared with ownCloudApp.framework

#import <ownCloudSDK/ownCloudSDK.h>

@interface OCCore (setNeedsToProcessSyncRecords)
Expand Down
56 changes: 4 additions & 52 deletions ownCloud Intents/Base.lproj/Intents.intentdefinition
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@
<key>INIntentDefinitionNamespace</key>
<string>K5U8aR</string>
<key>INIntentDefinitionSystemVersion</key>
<string>21E230</string>
<string>23G93</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>13E113</string>
<string>16A5230g</string>
<key>INIntentDefinitionToolsVersion</key>
<string>13.3</string>
<string>16.0</string>
<key>INIntents</key>
<array>
<dict>
Expand Down Expand Up @@ -943,7 +943,7 @@
<integer>13</integer>
<key>INIntentManagedParameterCombinations</key>
<dict>
<key>path,file,account,filename,fileextension,shouldOverwrite,waitForCompletion</key>
<key>path,file,account,filename,fileextension,shouldOverwrite</key>
<dict>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
Expand Down Expand Up @@ -1219,54 +1219,6 @@
<key>INIntentParameterType</key>
<string>Boolean</string>
</dict>
<dict>
<key>INIntentParameterConfigurable</key>
<true/>
<key>INIntentParameterDisplayName</key>
<string>Wait for upload to complete</string>
<key>INIntentParameterDisplayNameID</key>
<string>X18VvP</string>
<key>INIntentParameterDisplayPriority</key>
<integer>7</integer>
<key>INIntentParameterMetadata</key>
<dict>
<key>INIntentParameterMetadataFalseDisplayName</key>
<string>false</string>
<key>INIntentParameterMetadataFalseDisplayNameID</key>
<string>7Zv2I0</string>
<key>INIntentParameterMetadataTrueDisplayName</key>
<string>true</string>
<key>INIntentParameterMetadataTrueDisplayNameID</key>
<string>w1TCyX</string>
</dict>
<key>INIntentParameterName</key>
<string>waitForCompletion</string>
<key>INIntentParameterPromptDialogs</key>
<array>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Configuration</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogFormatString</key>
<string>Wait for upload to complete before continuing</string>
<key>INIntentParameterPromptDialogFormatStringID</key>
<string>Wt9Wgt</string>
<key>INIntentParameterPromptDialogType</key>
<string>Primary</string>
</dict>
</array>
<key>INIntentParameterSupportsResolution</key>
<true/>
<key>INIntentParameterTag</key>
<integer>13</integer>
<key>INIntentParameterType</key>
<string>Boolean</string>
</dict>
</array>
<key>INIntentResponse</key>
<dict>
Expand Down
82 changes: 20 additions & 62 deletions ownCloud Intents/SaveFileIntentHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public class SaveFileIntentHandler: NSObject, SaveFileIntentHandling, OCCoreDele
}
}
let filePath = path + newFilename
let waitForCompletion = (intent.waitForCompletion as? Bool) ?? false
let shouldOverwrite = (intent.shouldOverwrite as? Bool) ?? false

let completeWithCode = { (code: SaveFileIntentResponseCode) in
Expand Down Expand Up @@ -132,7 +131,7 @@ public class SaveFileIntentHandler: NSObject, SaveFileIntentHandling, OCCoreDele
if error == nil, let targetItem = item {
// Check if file already exists
OCItemTracker(for: bookmark, at: .legacyRootPath(filePath), waitOnlineTimeout: 5) { (error, core, fileItem) in
if let core = core {
if core != nil {
if error == nil, let fileItem = fileItem {
// File already exists
if !shouldOverwrite {
Expand All @@ -147,26 +146,10 @@ public class SaveFileIntentHandler: NSObject, SaveFileIntentHandling, OCCoreDele

OnBackgroundQueue {
if let parentItem = fileItem.parentItem(from: core) {
if waitForCompletion {
// Wait for completion: report local modification from extension
core.reportLocalModification(of: fileItem, parentItem: parentItem, withContentsOfFileAt: fileURL, isSecurityScoped: true, options: [OCCoreOption.importByCopying : true], placeholderCompletionHandler: nil, resultHandler: { (error, _, item, _) in
completeWithResult(error, item?.path)
})
} else {
// Delegate local modification report to File Provider
let fpServiceSession = OCFileProviderServiceSession(vault: core.vault)
self.fpServiceSession = fpServiceSession

let didStartSecurityScopedResource = fileURL.startAccessingSecurityScopedResource()

fpServiceSession.reportModificationThroughFileProvider(url: fileURL, as: fileItem.name, for: fileItem, to: parentItem, lastModifiedDate: nil, completion: { (error) in
completeWithResult(error, fileItem.path)

if didStartSecurityScopedResource {
fileURL.stopAccessingSecurityScopedResource()
}
})
}
// Wait for completion: report local modification from extension
core.reportLocalModification(of: fileItem, parentItem: parentItem, withContentsOfFileAt: fileURL, isSecurityScoped: true, options: [OCCoreOption.importByCopying : true], placeholderCompletionHandler: nil, resultHandler: { (error, _, item, _) in
completeWithResult(error, item?.path)
})
} else {
completeWithCode(.pathFailure)
}
Expand All @@ -178,39 +161,22 @@ public class SaveFileIntentHandler: NSObject, SaveFileIntentHandling, OCCoreDele
}
} else {
// File does NOT exist => import file
if waitForCompletion {
// Wait for completion: import from extension
OCCoreManager.shared.requestCore(for: bookmark, setup: { (core, error) in
core?.delegate = self
}, completionHandler: { (core, error) in
if let core = core {
self.core = core

OnBackgroundQueue {
core.importFileNamed(newFilename, at: targetItem, from: fileURL, isSecurityScoped: true, options: [OCCoreOption.importByCopying : true], placeholderCompletionHandler: nil, resultHandler: { (error, _, item, _) in
completeWithResult(error, item?.path)
})
}
} else {
completeWithResult(error, nil)
// Wait for completion: import from extension
OCCoreManager.shared.requestCore(for: bookmark, setup: { (core, error) in
core?.delegate = self
}, completionHandler: { (core, error) in
if let core = core {
self.core = core

OnBackgroundQueue {
core.importFileNamed(newFilename, at: targetItem, from: fileURL, isSecurityScoped: true, options: [OCCoreOption.importByCopying : true], placeholderCompletionHandler: nil, resultHandler: { (error, _, item, _) in
completeWithResult(error, item?.path)
})
}
})
} else {
// Delegate import to File Provider
let fpServiceSession = OCFileProviderServiceSession(vault: core.vault)
self.fpServiceSession = fpServiceSession

let didStartSecurityScopedResource = fileURL.startAccessingSecurityScopedResource()

fpServiceSession.importThroughFileProvider(url: fileURL, as: newFilename, to: targetItem, completion: { (error, _) in
let itemPath = (targetItem.path as NSString? ?? path as NSString?)?.appendingPathComponent(newFilename)
completeWithResult(error, itemPath)

if didStartSecurityScopedResource {
fileURL.stopAccessingSecurityScopedResource()
}
})
}
} else {
completeWithResult(error, nil)
}
})
}
} else {
failWithError(error)
Expand Down Expand Up @@ -276,14 +242,6 @@ public class SaveFileIntentHandler: NSObject, SaveFileIntentHandling, OCCoreDele
}
completion(INBooleanResolutionResult.success(with: shouldOverwrite))
}

func resolveWaitForCompletion(for intent: SaveFileIntent, with completion: @escaping (INBooleanResolutionResult) -> Void) {
var waitForCompletion = false
if let doWait = intent.waitForCompletion?.boolValue {
waitForCompletion = doWait
}
completion(INBooleanResolutionResult.success(with: waitForCompletion))
}
}

@available(iOS 13.0, *)
Expand Down
Loading
Loading