Posts

Post not yet marked as solved
0 Replies
68 Views
I recently added Swift compiler flags intended to catch concurrency warnings that will become errors in the future, adding -Xfrontend -warn-concurrency -enable-actor-data-race-checks to "Other Swift Flags" in my project build settings. These triggered both compile and runtime warnings about MainActor issues. The compile warns were about previews: Static property '_previews' isolated to global actor 'MainActor' can not satisfy corresponding requirement from protocol '_PreviewProvider', and Static property '_platform' isolated to global actor 'MainActor' can not satisfy corresponding requirement from protocol '_PreviewProvider' But more troubling is the runtime console message: warning: data race detected: @MainActor function at DataRace/DataRaceApp.swift:13 was not called on the main thread 2022-06-30 13:49:07.559517-0700 DataRace[2699:74516] warning: data race detected: @MainActor function at DataRace/DataRaceApp.swift:13 was not called on the main thread The problem appears to be within the SwiftUI framework itself, and is easy to replicate: Create a macOS SwiftUI document based app, I named my example "DataRace" Add -Xfrontend -warn-concurrency -enable-actor-data-race-checks to "Other Swift Flags" in the project build settings Change the Document declaration, changing it from a FileDocument to a ReferenceFileDocument, replacing fileWrapper() with the snapshot()/fileWrapper() required by ReferenceFileDocument: class DataRaceDocument: ReferenceFileDocument { var text: String init(text: String = "Hello, world!") { self.text = text } static var readableContentTypes: [UTType] { [.exampleText] } required init(configuration: ReadConfiguration) throws { guard let data = configuration.file.regularFileContents, let string = String(data: data, encoding: .utf8) else { throw CocoaError(.fileReadCorruptFile) } text = string } public func snapshot(contentType: UTType) throws -> Data { return text.data(using: .utf8)! } func fileWrapper(snapshot: Data, configuration: WriteConfiguration) throws -> FileWrapper { return .init(regularFileWithContents: snapshot) } } Change the App DocumentGroup to the one appropriate for ReferenceFileDocument: var body: some Scene { DocumentGroup(newDocument: { DataRaceDocument() }) { file in ContentView(document: file.document) } } } Lastly, change the ContentView to accommodate the previous changes: @ObservedObject var document: DataRaceDocument var body: some View { TextEditor(text: $document.text) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView(document: DataRaceDocument()) } } Compiling after these 4 changes will show the preview warnings. Run the app, save the default document, quit & restart the app and you will see the runtime warning. The line that triggers it is in the DocumentGroup statement in the App: DocumentGroup(newDocument: { DataRaceDocument() }) { file in ContentView(document: file.document) } and breakpoints show it happening before DataRaceDocument.init() is called Any ideas?
Posted Last updated
.
Post not yet marked as solved
1 Replies
203 Views
I am using scene.write(to:"dirpath\name.usdz") to get usdz export functionality into my app (universal, macOS & iOS). My problem is, it ceases to work after the first use, quitting & restarting the app is the only way to re-enable it. I have tried reusing the same scene, and instantiating a new scene (both ways with the exact same node structure), same results every time: first invocation writes a file of ~14MB, any calls after that write 1.5-2k of garbage. I use a unique filename for each write, and check to make sure it doesn't already exist. Any ideas?
Posted Last updated
.
Post not yet marked as solved
2 Replies
319 Views
Any USDZ file exported from Reality Composer fails to import into Reality Converter. Every USDZ file I have exported from Composer (even just a cube with a default glossy paint finish anchored on a horizontal surface) fails on import to Converter with the message "Conversion Failed: 1 Error". I suspect that the problem is with Composer and not Converter, since USDZ files created by other means import into Converter just fine. Steps to repro: Enable USDZ export in Reality Composer (Preferences/Enable USDZ export) Add a cube Export USDZ, current scene only (although this seems to make no difference) Open Reality Converter Drag USDZ file from step 3 into the window Observe error message Better import diagnostics would be good too.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.7k Views
I'm working with a designer to create SceneKit models for use with ARKit. She produces great work, but when she tries to export it to Collada (.dae), I get a mesh, but no textures. I've been through all the posts at blender.stackexchange.com, and searched the forums here, but I don't see anything relevant. We've done the step of UV Mapping the textures (one of the recurring themes in Collada export discussions on stackexchange), but no improvement. We've tried to debug the process by just doing a Blender -> Collada Export -> Import Collada > Blender round trip, and that fails (mesh returns, but all textures are lost). Interestingly, even when the "copy" is checked under the "textures" section of the export pane, no materials are copied into the target folder.Can anyone outline a workflow that successfully makes the round trip using a .png graphic as a texture? Just knowing whether or not the export is broken would be a step forward. Are there any 3rd party plugins for export? Help would be greatly appreciated!Thanks,Dan
Posted Last updated
.