How to disable Metal compiler warnings for SceneKit / ARKit?

The Metal compiler when invoked by SceneKit is generating a lot of spurious warnings in iOS / iPadOS 14 Beta 7 & 8. This seems to be causing a significant degradation in performance for our SceneKit/ARKit-based app.

Is there any way to disable this unnecessary Metal compiler logging? I tried making a MTLCOMPILERFLAGS = -w environment variable, but it didn't seem to have any effect.

Feedback ID FB8618939.

Logging looks like this:
2020-09-09 14:23:33.700122-0700 App[4672:1638397] [Metal Compiler Warning] Warning: Compilation succeeded with: 



programsource:95:26: warning: unused function 'reduceop'

    static inline float4 reduceop(float4 d0, float4 d1)

                         ^

program
source:581:26: warning: unused variable 'scnshadowsamplerordz'

static constexpr sampler scnshadowsamplerordz = sampler(coord::normalized, filter::linear, mipfilter::none, address::clamptoedge, comparefunc::greaterequal);

                         ^

2020-09-09 14:23:33.962519-0700 App[4672:1638397] [Metal Compiler Warning] Warning: Compilation succeeded with: 



program
source:95:26: warning: unused function 'reduceop'

    static inline float4 reduce
op(float4 d0, float4 d1)

                         ^

programsource:581:26: warning: unused variable 'scnshadowsamplerordz'

static constexpr sampler scn
shadowsamplerordz = sampler(coord::normalized, filter::linear, mipfilter::none, address::clamptoedge, comparefunc::greaterequal);
lenk,

By  "...after each reboot" I meant that the shader cache is cleared after each reboot of the device. Your shaders will also be cleared if you reinstall the app (after rebuilding, for instance).

The cache itself is quite large (255 MB on iOS devices), so it's unlikely that your shaders are getting ejected due to it filling up. You can only reduce the cache size from the default size by setting the MTL_SHADER_CACHE_SIZE env var (size in bytes). Since you can only reduce the size, this is really only useful for testing your uncached compilation time by setting it to 0.
Hello,
I've read through the posts in this thread and at last found out why a simple ARKit scene was freezing on the initial node rendering. I had the same problems mentioned by lenk while trying to use the SCNView.prepare methods.

Is there a workaround for this?

Thank you!
I tested the last iOS Beta (14.4 beta 2) and the problem is still present.

Adding nodes to the SceneView scene still hangs the app UI even when calling prepare. Sometimes, it also causes ARKit to lose the tracking. More importantly, the app freezes completely from time to time and cannot be recovered unless the app is killed. The user experience is terrible.

Any help or workaround is very welcome. At the moment, the only solution I see would be to move our app to Unity...
Has there been any updates on this, or has anyone managed to find a work around? It still appears to be affecting out ARKit app.
I still have not found a workaround and the performance is still terrible in today's iOS 14.5 Beta 3 and macOS 11.3 Beta 3 builds.
Hello,

Same issue here since iOS14.
Still haven't found any workaround ;(

Still no improvement in this week's iOS 14.5 Beta 4 and macOS 11.3 Beta 4. And still no help from Apple on a workaround. Sigh.

I got the following response from Apple's feedback assistant regarding the issue,

Our team had a similar issue with Metal Compiler Warning in the Xcode console log. One side note is that even though the Xcode log says that it is a Warning, the Xcode Instruments tool says it's an Error.

I was able to spend a 1/2 hour with two Metal engineers during WWDC Lab hours. The discussion with that team was useful and hopefully this helps others down the line:

  • Be sure to test outside of Xcode, as Xcode does Extra Metal Validation. Here are two entries in our log related at the start of the Metal portion of the code.
    • Metal GPU Frame Capture Enabled
    • Metal API Validation Enabled
  • In the Simulator, the container path changes, possibly every time (TBD), which could cause the Metal code to be re-compiled
  • While using instrumentation via Xcode Instruments, be sure to watch for the MetalCompilerService in Instruments and the Console logs.
  • Verify if the Metal Compiler Warnings go away in the condition after a reboot (“ this is expected to happen”).
How to disable Metal compiler warnings for SceneKit / ARKit?
 
 
Q