'RealityKit – Text mesh resource performance warning
I have an object in RealityKit
that I hover some text over. I make the text using the built in static function on MeshResource
like this.
let textMesh = MeshResource.generateText("Some text", extrusionDepth: 0.01, font: MeshResource.Font.systemFont(ofSize: 0.05), containerFrame: .zero, alignment: .center, lineBreakMode: .byTruncatingTail)
let material = SimpleMaterial(color: .green, isMetallic: false)
let textEntity = ModelEntity(mesh: textMesh, materials: [material])
The text shows up but I get warnings from ARKit
(RealityKit
) about using a wrong font type and something about performance? These logs fill up my terminal because I actually update the text in the ARView
regularly. This is how I update the text.
let textMesh = MeshResource.generateText("Some new text", extrusionDepth: 0.01, font: MeshResource.Font.systemFont(ofSize: 0.05), containerFrame: .zero, alignment: .center, lineBreakMode: .byTruncatingTail)
//textEntity variable gets stored in my app so I can keep track of it / them out side ARView
textEntity?.model?.mesh = textMesh
Here is the warning. I get hundreds of them but I'll only burden you with one.
CoreText performance note: Client called CTFontCreateWithName() using name "System Font Regular" and got font with PostScript name ".SFUI-Regular". For best performance, only use PostScript names when calling this API.
I would prefer to resolve this warning but if I can't and it's just something I have to live with until Apple iterates this framework can I at least silence it somehow?
Solution 1:[1]
Solution
You can try Helvetica font. But there's no 100% guarantee that it'll fix the issue in any Xcode version.
let textEntity = ModelEntity(mesh: .generateText("RealityKit",
font: .init(name: "Helvetica", size: 0.5)!))
But 99% of the time it worked.
About warnings
Console warnings come from RealityKit .cpp
files. To silence them, go to Xcode menu Product
–> Scheme
–> Edit Scheme
and add to environment dictionary OS_ACTIVITY_MODE
key with its corresponding disable
value.
OS_ACTIVITY_MODE = disable
At the moment, it's the most efficient way to disable RealityKit 2.0 warnings.
You can check this in ViewController with:
print(ProcessInfo.processInfo.environment["OS_ACTIVITY_MODE"])
// Result: disable
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |