I found a workaround. The CIImage that was queued for feedback had several Kernel filters applied to it. This seemed to be the cause of the memory issue. My workaround is to convert the CIImage to NSImage and then back to CIImage when adding it to the feedback queue. The CIImage from the NSImage has eliminated all of the intermediate operations that were in the original CIImage.
This is not very elegant, but it works. The virtual memory size is rock solid.
Post not yet marked as solved
after a lot of trial and error, I was able to fix the problem. I added the line with the comment below.
exportProgressChecker = AssetExporter.exportAsynchronously(exportFileURL: dialog.url!) {
if self.exportProgressChecker != nil && self.exportProgressChecker!.succeeded {
self.showingExportProgress = false // adding this line fixed the issue.
self.triggerAlert(reason: .exportDone)
Post not yet marked as solved
Ok I've made a little progress. In ContentView.swift, there is a section of code that is trying to display the "Export Finished" alert. But the "Export Progress" alert is still being displayed at 100%. I've put a comment in the code where I think there needs to be some statement to close the "Export Progress" popup. I have no idea of how to do that.
alert(isPresented: $showingAlert) {
switch alertReason {
... )
case .exportDone:
// need to close the previous alert for export progress!!!
return Alert(title: Text("Export finished"), message: nil, dismissButton: Alert.Button.default(Text("OK"), action: {
self.showingExportProgress = false
})) .sheet(isPresented: $showingExportProgress) {
ProgressPopup(isVisible: self.$showingExportProgress, title: Text("Exporting ..."), progressUpdateHandler: { () -> Float in
return self.exportProgressChecker?.progress ?? 0
})
}
The ProgressPopup is a struct:
struct ProgressPopup: View { ...
Questions:
Can I add a .close() function to the struct that would tell it to go away? What would it look like?
The ProgressPopup is displayed with this statement:
.sheet(isPresented: $showingExportProgress) {
ProgressPopup(isVisible: self.$showingExportProgress, title: Text("Exporting ..."), progressUpdateHandler: { () -> Float in
return self.exportProgressChecker?.progress ?? 0
})
}
But there doesn't seem to be a variable that saves a reference to it anywhere, so even if I could make a close() function from question 1, I would still need to be able to invoke the new function to close the popup.
Thanks to all for reading!
Thank you for posting the answer! Worked great.