Skip to content

Commit

Permalink
Merge pull request #140 from tumblr/fix/multi-export-crash
Browse files Browse the repository at this point in the history
Reduce renderer memory consumption when exporting
  • Loading branch information
afterxleep authored Jul 8, 2022
2 parents 78f8f86 + 9dbb644 commit 2743f5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Classes/Editor/MultiEditor/MultiEditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ extension MultiEditorViewController: EditorControllerDelegate {
editor.export { [weak self, editor] result in
let _ = editor // strong reference until the export completes
self?.exportHandler.handleExport(result, for: idx)
if let selected = self?.selected {
self?.loadEditor(for: selected, current: false)
}
}
}
})

if let selected = self.selected {
loadEditor(for: selected, current: true)
}

return false
}

Expand Down
4 changes: 3 additions & 1 deletion Classes/Rendering/Renderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ final class Renderer: Rendering {
/// For this to work, all access to filteredPixelBuffer should be locked, so this method should be called in
/// a synchronized(self) block.
private func output(filteredPixelBuffer: CVPixelBuffer) {
guard let delegate = self.delegate else { return }

self.filteredPixelBuffer = filteredPixelBuffer
callbackQueue.async {
let pixelBuffer: CVPixelBuffer? = synchronized(self) {
Expand All @@ -173,7 +175,7 @@ final class Renderer: Rendering {
return pixelBuffer
}
if let filteredPixelBuffer = pixelBuffer {
self.delegate?.rendererReadyForDisplay(pixelBuffer: filteredPixelBuffer)
delegate.rendererReadyForDisplay(pixelBuffer: filteredPixelBuffer)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Kanvas.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Pod::Spec.new do |spec|
spec.name = 'Kanvas'
spec.version = '1.4.2'
spec.version = '1.4.3'
spec.summary = 'A custom camera built for iOS.'
spec.homepage = 'https://github.com/tumblr/kanvas-ios'
spec.license = 'MPLv2'
Expand Down

0 comments on commit 2743f5a

Please sign in to comment.