Skip to content

Commit

Permalink
[Fix]Frame scaled to fill without respecting content mode (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Nov 12, 2024
1 parent 05fe4e1 commit fb5654c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Upcoming

### 🔄 Changed
### 🐞 Fixed
- When joining one call after another, the last frame of the previous call was flashing for a split second in the new call [#596](https://github.com/GetStream/stream-video-swift/pull/596)

# [1.14.0](https://github.com/GetStream/stream-video-swift/releases/tag/1.14.0)
_November 06, 2024_
Expand Down
5 changes: 2 additions & 3 deletions Sources/StreamVideoSwiftUI/Utils/ReusePool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ final class ReusePool<Element: AnyObject & Hashable> {
///
/// - Parameters:
/// - element: The element to release.
/// - replaceAvailableElementWithNew: If set to `true` rather than moving the item to
/// available, it will throw it away and instead place a newly created element in `available` storage.
/// Defaults to `false`.
func release(_ element: Element, replaceAvailableElementWithNew: Bool = false) {
func release(_ element: Element) {
queue.sync {
if inUse.contains(element), available.endIndex < initialCapacity {
inUse.remove(element)
available.append(replaceAvailableElementWithNew ? factory() : element)
available.append(element)
log.debug("Will make available \(type(of: element)):\(String(describing: element)).")
} else {
inUse.remove(element)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ final class VideoRendererPool {

/// Initializes the `VideoRendererPool` with a specified initial capacity.
///
/// - Parameter initialCapacity: The initial capacity of the pool (default is 2).
init(initialCapacity: Int = 2) {
/// - Parameter initialCapacity: The initial capacity of the pool (default is 0).
init(initialCapacity: Int = 0) {
// Initialize the pool with a capacity and a factory closure to create `VideoRenderer` instances
pool = ReusePool(initialCapacity: initialCapacity) {
VideoRenderer(frame: CGRect(origin: .zero, size: .zero))
Expand All @@ -43,7 +43,7 @@ final class VideoRendererPool {
///
/// - Parameter renderer: The `VideoRenderer` instance to release.
func releaseRenderer(_ renderer: VideoRenderer) {
pool.release(renderer, replaceAvailableElementWithNew: true)
pool.release(renderer)
}
}

Expand Down
8 changes: 4 additions & 4 deletions StreamVideoSwiftUITests/Utils/ReusePool_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ final class ReusePoolTests: XCTestCase {
XCTAssertNotNil(object2)
XCTAssertNotEqual(object1, object2)

subject.release(object2, replaceAvailableElementWithNew: true)
subject.release(object1, replaceAvailableElementWithNew: true)
subject.release(object2)
subject.release(object1)

// After releasing, these objects should be available for reuse
let object3 = subject.acquire()
let object4 = subject.acquire()

XCTAssertNotNil(object3)
XCTAssertNotNil(object4)
XCTAssertFalse(object1 === object3) // Reused object
XCTAssertFalse(object2 === object4) // Reused object
XCTAssertTrue(object1 === object3) // Reused object
XCTAssertTrue(object2 === object4) // Reused object

// Now, the pool should be at initial capacity
let object5 = subject.acquire()
Expand Down

0 comments on commit fb5654c

Please sign in to comment.