Post

Replies

Boosts

Views

Activity

AppIntents crashes in prod
We implemented AppIntents using EnumerableEntityQuery and @Dependency and we are receiving these crash reports: AppIntents/AppDependencyManager.swift:120: Fatal error: AppDependency of type MyDependency.Type was not initialized prior to access. Dependency values can only be accessed inside of the intent perform flow and within types conforming to _SupportsAppDependencies unless the value of the dependency is manually set prior to access. I can't post the stack because of the Developer Forums sensitive language filter :( but basically it's just a call to suggestedEntities of MyEntityQuery that calls the dependency getter and then it crashes. My understanding was that when using @Dependency, the execution of the intent, or query of suggestedEntities in this case, would be delayed by the AppIntents framework until the dependency was added to the AppDependencyManager by me. At least that's what's happening in my tests. But in prod I'm having these crashes which I haven't been able to reproduce in dev yet. Does anyone know if this is a bug or how can this be fixed? As a workaround, I can avoid using @Dependency and AppDependencyManager completely and make sure that all operations are async and delay the execution myself until the dependency is set. But I'd like to know if there's a better solution. Thanks!
1
0
255
Oct ’25
kAudioUnitSubType_VoiceProcessingIO volume really low with specific devices
I am trying to setup a kAudioUnitSubType_VoiceProcessingIO audio unit for a VoIP macOS app. I tried kAudioUnitSubType_HALOutput first, but it was not suitable due to echo and noise, which makes sense. kAudioUnitSubType_VoiceProcessingIO seemed promising. However, when using it with a bluetooth headset for output and built-in mic for input, volume gets really low compared to other device setups such as both internal input and output, or both bluetooth headset input and output. The alternative setups seem to work fine, but we can't request users to avoid specific setups. This makes kAudioUnitSubType_VoiceProcessingIO unusable for a macOS app. Is kAudioUnitSubType_VoiceProcessingIO production ready for current macOS apps? Is there any way to avoid the volume issues? Adding manual gain is not a workaround because voice becomes really distorted. Thanks.
1
0
1.3k
Jul ’23
Have a fullSizeContentView NSWindow taking the size of a SwiftUI view
I want an NSWindow with fullSizeContentView to take the exact size of a SwiftUI view that has an "intrinsic" content size. I know I could use a frame at the top with a fixed size and that works but I can't do that since the content is dynamic. I want SwiftUI to compute the width and height of the content view and to have the window size to be exactly the size of the view. How can I do that? This is a Playground snippet that runs in Xcode 14.1. import AppKit import SwiftUI class MyWindow: NSWindow { override func setFrame(_ frameRect: NSRect, display flag: Bool) { print("\(Date().timeIntervalSince1970) setFrame called \(frameRect)") super.setFrame(frameRect, display: flag) } } let window = MyWindow() window.styleMask = [ .titled, .closable, .resizable, .fullSizeContentView ] window.toolbar = nil window.titlebarAppearsTransparent = true window.titleVisibility = .hidden window.isMovable = true window.isMovableByWindowBackground = true window.standardWindowButton(.closeButton)?.isHidden = false window.standardWindowButton(.miniaturizeButton)?.isHidden = true window.standardWindowButton(.zoomButton)?.isHidden = true print("\(Date().timeIntervalSince1970) Before content \(window.frame)") window.contentView = NSHostingView(rootView: ContentView()) print("\(Date().timeIntervalSince1970) After setting content \(window.frame)") window.makeKeyAndOrderFront(nil) print("\(Date().timeIntervalSince1970) After makeKeyAndOrderFront \(window.frame)") DispatchQueue.main.asyncAfter(deadline: .now() + 1) { print("\(Date().timeIntervalSince1970) After 1 second \(window.frame)") } struct ContentView: View { var body: some View { Text("Hello") .font(.system(size: 200)) .background(.blue) .fixedSize() .ignoresSafeArea() } } The problem is that it leaves some space at the end. Why is this code behaving like that?  It prints this: 1674086812.362426 setFrame called (100.0, 100.0, 100.0, 100.0) 1674086812.363435 Before content (100.0, 100.0, 100.0, 100.0) 1674086812.373186 setFrame called (100.0, -63.0, 431.0, 263.0) 1674086812.3741732 After setting content (100.0, -63.0, 431.0, 263.0) 1674086812.374618 setFrame called (100.0, 85.0, 431.0, 263.0) 1674086812.375651 After makeKeyAndOrderFront (100.0, 85.0, 431.0, 263.0) 1674086812.4359 setFrame called (100.0, 57.0, 431.0, 291.0) 1674086813.41998 After 1 second (198.0, 99.0, 431.0, 291.0) Why is SwiftUI setting the frame with a different size after showing it?
2
0
1.5k
Jan ’23
AppIntents crashes in prod
We implemented AppIntents using EnumerableEntityQuery and @Dependency and we are receiving these crash reports: AppIntents/AppDependencyManager.swift:120: Fatal error: AppDependency of type MyDependency.Type was not initialized prior to access. Dependency values can only be accessed inside of the intent perform flow and within types conforming to _SupportsAppDependencies unless the value of the dependency is manually set prior to access. I can't post the stack because of the Developer Forums sensitive language filter :( but basically it's just a call to suggestedEntities of MyEntityQuery that calls the dependency getter and then it crashes. My understanding was that when using @Dependency, the execution of the intent, or query of suggestedEntities in this case, would be delayed by the AppIntents framework until the dependency was added to the AppDependencyManager by me. At least that's what's happening in my tests. But in prod I'm having these crashes which I haven't been able to reproduce in dev yet. Does anyone know if this is a bug or how can this be fixed? As a workaround, I can avoid using @Dependency and AppDependencyManager completely and make sure that all operations are async and delay the execution myself until the dependency is set. But I'd like to know if there's a better solution. Thanks!
Replies
1
Boosts
0
Views
255
Activity
Oct ’25
kAudioUnitSubType_VoiceProcessingIO volume really low with specific devices
I am trying to setup a kAudioUnitSubType_VoiceProcessingIO audio unit for a VoIP macOS app. I tried kAudioUnitSubType_HALOutput first, but it was not suitable due to echo and noise, which makes sense. kAudioUnitSubType_VoiceProcessingIO seemed promising. However, when using it with a bluetooth headset for output and built-in mic for input, volume gets really low compared to other device setups such as both internal input and output, or both bluetooth headset input and output. The alternative setups seem to work fine, but we can't request users to avoid specific setups. This makes kAudioUnitSubType_VoiceProcessingIO unusable for a macOS app. Is kAudioUnitSubType_VoiceProcessingIO production ready for current macOS apps? Is there any way to avoid the volume issues? Adding manual gain is not a workaround because voice becomes really distorted. Thanks.
Replies
1
Boosts
0
Views
1.3k
Activity
Jul ’23
Have a fullSizeContentView NSWindow taking the size of a SwiftUI view
I want an NSWindow with fullSizeContentView to take the exact size of a SwiftUI view that has an "intrinsic" content size. I know I could use a frame at the top with a fixed size and that works but I can't do that since the content is dynamic. I want SwiftUI to compute the width and height of the content view and to have the window size to be exactly the size of the view. How can I do that? This is a Playground snippet that runs in Xcode 14.1. import AppKit import SwiftUI class MyWindow: NSWindow { override func setFrame(_ frameRect: NSRect, display flag: Bool) { print("\(Date().timeIntervalSince1970) setFrame called \(frameRect)") super.setFrame(frameRect, display: flag) } } let window = MyWindow() window.styleMask = [ .titled, .closable, .resizable, .fullSizeContentView ] window.toolbar = nil window.titlebarAppearsTransparent = true window.titleVisibility = .hidden window.isMovable = true window.isMovableByWindowBackground = true window.standardWindowButton(.closeButton)?.isHidden = false window.standardWindowButton(.miniaturizeButton)?.isHidden = true window.standardWindowButton(.zoomButton)?.isHidden = true print("\(Date().timeIntervalSince1970) Before content \(window.frame)") window.contentView = NSHostingView(rootView: ContentView()) print("\(Date().timeIntervalSince1970) After setting content \(window.frame)") window.makeKeyAndOrderFront(nil) print("\(Date().timeIntervalSince1970) After makeKeyAndOrderFront \(window.frame)") DispatchQueue.main.asyncAfter(deadline: .now() + 1) { print("\(Date().timeIntervalSince1970) After 1 second \(window.frame)") } struct ContentView: View { var body: some View { Text("Hello") .font(.system(size: 200)) .background(.blue) .fixedSize() .ignoresSafeArea() } } The problem is that it leaves some space at the end. Why is this code behaving like that?  It prints this: 1674086812.362426 setFrame called (100.0, 100.0, 100.0, 100.0) 1674086812.363435 Before content (100.0, 100.0, 100.0, 100.0) 1674086812.373186 setFrame called (100.0, -63.0, 431.0, 263.0) 1674086812.3741732 After setting content (100.0, -63.0, 431.0, 263.0) 1674086812.374618 setFrame called (100.0, 85.0, 431.0, 263.0) 1674086812.375651 After makeKeyAndOrderFront (100.0, 85.0, 431.0, 263.0) 1674086812.4359 setFrame called (100.0, 57.0, 431.0, 291.0) 1674086813.41998 After 1 second (198.0, 99.0, 431.0, 291.0) Why is SwiftUI setting the frame with a different size after showing it?
Replies
2
Boosts
0
Views
1.5k
Activity
Jan ’23