Rate limit from SensitiveContentAnalysisML never lifts when using PCC

I keep running into rate limit issues that never go away while the app is running when trying to analyze images using Private Cloud Compute in iOS 27 Beta 6.

After 20 or so images, I get a rate limit error from PCC, but the actual rate limit seems to come from SCML (see relevant log entries below). Once this happens, any attempted PCC requests result in an immediate rate limit error, no matter how long I wait, so long as the app is running.

If I kill the app and relaunch, I no longer receive the rate limit error (unless, again I run several images through in succession). So it seems like once this state is triggered, you are stuck in it until you kill and relaunch the app.

Has anyone else encountered this or have a workaround? I've filed a feedback already: FB24419603

Passing along Client rate limit exceeded, try again later in response to ExecuteRequest
Passing along Client rate limit exceeded, try again later in response to ExecuteRequest
systemPromptID failed for task textSafety: Rate limited. Wait a little bit and then try again.::Rate limited. Wait a little bit and then try again.: Client rate limit exceeded, try again later::Client rate limit exceeded, try again later; prompt template also not found: Rate limited. Wait a little bit and then try again.::Rate limited. Wait a little bit and then try again.: Client rate limit exceeded, try again later::Client rate limit exceeded, try again later
End sanitizeText with error: Error Domain=com.apple.SensitiveContentAnalysisML Code=15 "SCML.CombinedTextSanitizerBackend.BackendError("SafetyGuardrailTextSanitizerBackend"): Rate limited. Wait a little bit and then try again." UserInfo={NSLocalizedDescription=SCML.CombinedTextSanitizerBackend.BackendError("SafetyGuardrailTextSanitizerBackend"): Rate limited. Wait a little bit and then try again., NSUnderlyingError=0x11a632ee0 {Error Domain=SensitiveContentAnalysisML.CombinedTextSanitizerBackend.BackendError Code=1 "SCML.CombinedTextSanitizerBackend.BackendError("SafetyGuardrailTextSanitizerBackend"): Rate limited. Wait a little bit and then try again." UserInfo={NSUnderlyingError=0x11a5dd380 {Error Domain=com.apple.GenerativeFunctionsFoundation.GenerativeError Code=1010000 "Rate limited. Wait a little bit and then try again."}, NSLocalizedDescription=SCML.CombinedTextSanitizerBackend.BackendError("SafetyGuardrailTextSanitizerBackend"): Rate limited. Wait a little bit and then try again.}}}
Answered by Enderlyn in 902247022

I got it working and hopefully this will help someone else. And maybe someone who understands more about this can fill in some details as to why this is happening.

In this particular case, image classification was occurring from a live camera view whenever a photo was taken. It was happening on its own task.

The rate limit appears to have occurred in ModelManagerServices (subsystem com.apple.modelmanager, category IPC) and then passed up.

It would happen consistently in this portion of the app after processing several photos (I had originally thought it was around 20, but it was usually closer to 12-18, depending on the device).

After you hit the limit in this part of the app, you would continue to get the rate limit error from then on every time it tried to analyze the image, even if you went away to another section of then came back to it later or just waited a while. The only way to get it working again was to kill the app and re-launch.

However, there are other parts of the app that use the same code for analyzing images and none of them exhibited this problem. In fact, you could hit the rate limit in the camera view, go to another section and processing a bunch of images from files, and the app would truck along fine, calling the same image classification code. Go back to the camera view and you'd get the rate limit immediately.

I tried everything I could think of, including enforcing long pauses between photos, tearing down the AVCapture session after each was taken and then standing it back up again after the photo was analyzed, scaling the images even smaller, lowering the priority of the task, and a host of other things. Nothing worked.

Then finally, I tried presenting the UI that shows during the analysis (and thus calls the analysis code) as its own modal sheet (the camera view itself being one) and it worked.

I don't know why this works, but I'm not getting the rate limit anymore.

One thing to note: This does not seem to happen in the Catalyst version of the app running on macOS 27 Beta 6. Just on iOS.

Accepted Answer

I got it working and hopefully this will help someone else. And maybe someone who understands more about this can fill in some details as to why this is happening.

In this particular case, image classification was occurring from a live camera view whenever a photo was taken. It was happening on its own task.

The rate limit appears to have occurred in ModelManagerServices (subsystem com.apple.modelmanager, category IPC) and then passed up.

It would happen consistently in this portion of the app after processing several photos (I had originally thought it was around 20, but it was usually closer to 12-18, depending on the device).

After you hit the limit in this part of the app, you would continue to get the rate limit error from then on every time it tried to analyze the image, even if you went away to another section of then came back to it later or just waited a while. The only way to get it working again was to kill the app and re-launch.

However, there are other parts of the app that use the same code for analyzing images and none of them exhibited this problem. In fact, you could hit the rate limit in the camera view, go to another section and processing a bunch of images from files, and the app would truck along fine, calling the same image classification code. Go back to the camera view and you'd get the rate limit immediately.

I tried everything I could think of, including enforcing long pauses between photos, tearing down the AVCapture session after each was taken and then standing it back up again after the photo was analyzed, scaling the images even smaller, lowering the priority of the task, and a host of other things. Nothing worked.

Then finally, I tried presenting the UI that shows during the analysis (and thus calls the analysis code) as its own modal sheet (the camera view itself being one) and it worked.

I don't know why this works, but I'm not getting the rate limit anymore.

Thanks for reporting @Enderlyn! Filing a feedback with a sysdiagnose is incredibly helpful, since that gives us the signals we need to tell what happened.

I've passed this on to the experts, but my guess is you're seeing a difference between background processes and foreground processes. Running a LanguageModelSession from a background task or background thread (from any model) gets rate limited by the operating system. So I'm guessing the PCC limit is interacting with the background inference limit here.

Rate limit from SensitiveContentAnalysisML never lifts when using PCC
 
 
Q