Posts

Post not yet marked as solved
0 Replies
1.4k Views
In What's New In Swift, a new DispatchSerialQueue-backed actor was introduced. We're able to call MainActor-annotated functions using DispatchQueue.main.async without errors or warnings. For example: @MainActor func randomFunc() { print("Hello World") } DispatchQueue.main.async { randomFunc() } However calling a globalActor-annotated function or a regular actor-isolated function backed by a DispatchSerialQueue, we get the warning Actor-isolated instance method 'randomFunc()' can not be referenced from a non-isolated context; this is an error in Swift 6. Code here: actor MyActor { private let queue: DispatchSerialQueue nonisolated var unownedExecutor: UnownedSerialExecutor { queue.asUnownedSerialExecutor() } init(queue: DispatchSerialQueue) { self.queue = queue } func randomFunc() { print("Hello World!") } } let queue = DispatchSerialQueue(label: "actorQueue") let actor = MyActor(queue: queue) queue.async { actor.randomFunc() // Warning here } Although it has a warning, the code still runs successfully and prints Hello World, but it would also do so from another DispatchQueue not used by the actor (this was tested in Version 15.0 beta (15A5160n) Playground). My question: Can we remove the warning resulting from calling an actor isolated function backed by DispatchSerialQueue A using A.async { }, if that's safe behavior? If it's not safe, why not?
Posted
by achouman.
Last updated
.
Post not yet marked as solved
0 Replies
722 Views
I'm trying to get the width and height of an HLS AVPlayer in PiP mode. It seems that you would get this in the videoRect attribute of AVPlayerLayer, but it doesn't seem to update correctly in PiP or background modes (playing a video's audio while in lock screen for example doesn't update width and height to 0 as expected). Any ideas on how to get the video resolution/dimension while in PictureInPicture?
Posted
by achouman.
Last updated
.