Time-sensitive threads

Games want to get as much performance as they possibly can from the system. To support this, some of the game's threads are time-sensitive in that they don't want any unexpectedly long-running operations to take place on those threads. A canonical example of a time-sensitive thread is the one used for the game's rendering.

The Gaming Runtime Services (GRTS) makes it a little bit easier to identify what APIs aren't safe to call on a time-sensitive thread.

Note

You can identify GRTS APIs because they begin with "X" (for example, XGameSaveInitializeProvider or XGameGetXboxTitleId).

For the identification system to work, games need to call XThreadSetTimeSensitive on their time-sensitive threads. This API stores a bit in thread local storage that can be queried by GRTS APIs.

A GRTS API that's considered safe to call on a time-sensitive thread will exhibit a consistent runtime performance when given the same input. If a GRTS API isn't safe to call on a time-sensitive thread, the GRTS API has an internal call to XThreadAssertNotTimeSensitive. If the unsafe function is called on a thread that has been marked as time-sensitive, the following happens.

  • If a debugger is attached, an assert gets triggered and the developer is informed of the violation. Developers also get instructed on how they can then globally disable the breakpoints.
  • An Event Tracing for Windows (ETW) event is emitted that can be viewed in XbWatson (NDA topic)Authorization required.

Unsafe functions for time-sensitive threads

The following GRTS API functions aren't safe to call on time-sensitive threads. All other GRTS API functions are time-sensitive–safe and can be called on time-sensitive threads.

Networking API

Header Function
XNetworking XNetworkingQueryPreferredLocalUdpMultiplayerPort
XNetworking XNetworkingUnregisterConnectivityHintChanged
XNetworking XNetworkingUnregisterPreferredLocalUdpMultiplayerPortChanged
XNetworking XNetworkingVerifyServerCertificate

System API

Header Function
XAccessibility XClosedCaptionGetProperties
XAccessibility XClosedCaptionSetEnabled
XAccessibility XHighContrastGetMode
XAccessibility XSpeechToTextSendString
XAccessibility XSpeechToTextSetPositionHint
XAppCapture XAppBroadcastGetStatus
XAppCapture XAppBroadcastIsAppBroadcasting
XAppCapture XAppBroadcastRegisterIsAppBroadcastingChanged
XAppCapture XAppBroadcastShowUI
XAppCapture XAppBroadcastUnregisterIsAppBroadcastingChanged
XAppCapture XAppCaptureCloseScreenshotStream
XAppCapture XAppCaptureDisableRecord
XAppCapture XAppCaptureEnableRecord
XAppCapture XAppCaptureMetadataAddDoubleEvent
XAppCapture XAppCaptureMetadataAddInt32Event
XAppCapture XAppCaptureMetadataAddStringEvent
XAppCapture XAppCaptureMetadataRemainingStorageBytesAvailable
XAppCapture XAppCaptureMetadataStartDoubleState
XAppCapture XAppCaptureMetadataStartInt32State
XAppCapture XAppCaptureMetadataStartStringState
XAppCapture XAppCaptureMetadataStopAllStates
XAppCapture XAppCaptureMetadataStopState
XAppCapture XAppCaptureOpenScreenshotStream
XAppCapture XAppCaptureReadScreenshotStream
XAppCapture XAppCaptureRecordDiagnosticClip
XAppCapture XAppCaptureRegisterMetadataPurged
XAppCapture XAppCaptureTakeDiagnosticScreenshot
XAppCapture XAppCaptureTakeScreenshot
XAppCapture XAppCaptureUnRegisterMetadataPurged
XAsyncProvider XAsyncComplete
XDisplay XDisplayAcquireTimeoutDeferral
XDisplay XDisplayCloseTimeoutDeferralHandle
XDisplay XDisplayTryEnableHdrMode
XError XErrorSetCallback
XError XErrorSetOptions
XGame XGameGetXboxTitleId
XGame XLaunchNewGame
XGameEvent XGameEventWrite
XGameInvite XGameInviteRegisterForEvent
XGameInvite XGameInviteUnregisterForEvent
XGameSave XGameSaveCloseContainer
XGameSave XGameSaveCloseProvider
XGameSave XGameSaveCloseUpdate
XGameSave XGameSaveCreateContainer
XGameSave XGameSaveCreateUpdate
XGameSave XGameSaveDeleteContainer
XGameSave XGameSaveEnumerateBlobInfo
XGameSave XGameSaveEnumerateBlobInfoByName
XGameSave XGameSaveEnumerateContainerInfo
XGameSave XGameSaveEnumerateContainerInfoByName
XGameSave XGameSaveGetContainerInfo
XGameSave XGameSaveGetRemainingQuota
XGameSave XGameSaveInitializeProvider
XGameSave XGameSaveReadBlobData
XGameSave XGameSaveSubmitBlobDelete
XGameSave XGameSaveSubmitBlobWrite
XGameSave XGameSaveSubmitUpdate
XGameStreaming XGameStreamingGetStreamAddedLatency
XGameStreaming XGameStreamingInitialize
XGameStreaming XGameStreamingRegisterClientPropertiesChanged
XGameStreaming XGameStreamingRegisterConnectionStateChanged
XGameStreaming XGameStreamingUninitialize
XGameStreaming XGameStreamingUnregisterClientPropertiesChanged
XGameStreaming XGameStreamingUnregisterConnectionStateChanged
XGameUI XGameUiSetNotificationPositionHint
XLauncher XLaunchUri
XPackage XPackageChangeChunkInstallOrder
XPackage XPackageCloseMountHandle
XPackage XPackageCreateInstallationMonitor
XPackage XPackageEnumerateChunkAvailability
XPackage XPackageEnumeratePackages
XPackage XPackageEstimateDownloadSize
XPackage XPackageFindChunkAvailability
XPackage XPackageGetMountPath
XPackage XPackageGetMountPathSize
XPackage XPackageGetUserLocale
XPackage XPackageInstallChunks
XPackage XPackageMount
XPackage XPackageUninstallChunks
XPackage XPackageUnregisterInstallationProgressChanged
XPackage XPackageUnregisterPackageInstalled
XPackage XPackageUpdateInstallationMonitor
XPersistentLocalStorage XPersistentLocalStorageGetPath
XPersistentLocalStorage XPersistentLocalStorageGetPathSize
XPersistentLocalStorage XPersistentLocalStorageMountForPackage
XSpeechSynthesizer XSpeechSynthesizerCloseHandle
XSpeechSynthesizer XSpeechSynthesizerCloseStreamHandle
XSpeechSynthesizer XSpeechSynthesizerCreate
XSpeechSynthesizer XSpeechSynthesizerCreateStreamFromText
XSpeechSynthesizer XSpeechSynthesizerEnumerateInstalledVoices
XSpeechSynthesizer XSpeechSynthesizerGetStreamData
XSpeechSynthesizer XSpeechSynthesizerGetStreamDataSize
XSpeechSynthesizer XSpeechSynthesizerSetCustomVoice
XSpeechSynthesizer XSpeechSynthesizerSetDefaultVoice
XStore XStoreCloseContextHandle
XStore XStoreCloseLicenseHandle
XStore XStoreCloseProductsQueryHandle
XStore XStoreCreateContext
XStore XStoreEnumerateProductsQuery
XStore XStoreUnregisterGameLicenseChanged
XStore XStoreUnregisterPackageLicenseLost
XSystem XSystemAllowFullDownloadBandwidth
XSystem XSystemGetAnalyticsInfo
XSystem XSystemGetConsoleId
XSystem XSystemGetXboxLiveSandboxId
XTaskQueue XTaskQueueCreate
XTaskQueue XTaskQueueCreateComposite
XTaskQueue XTaskQueueGetCurrentProcessTaskQueue
XTaskQueue XTaskQueueGetPort
XTaskQueue XTaskQueueRegisterMonitor
XTaskQueue XTaskQueueRegisterWaiter
XTaskQueue XTaskQueueSetCurrentProcessTaskQueue
XTaskQueue XTaskQueueTerminate
XTaskQueue XTaskQueueUnregisterMonitor
XTaskQueue XTaskQueueUnregisterWaiter
XUser XUserCloseHandle
XUser XUserCloseSignOutDeferralHandle
XUser XUserFindForDevice
XUser XUserFindUserById
XUser XUserFindUserByLocalId
XUser XUserGetDefaultAudioEndpointUtf16
XUser XUserRegisterForChangeEvent
XUser XUserRegisterForDefaultAudioEndpointUtf16Changed
XUser XUserRegisterForDeviceAssociationChanged
XUser XUserUnregisterForChangeEvent
XUser XUserUnregisterforDefaultAudioEndpointUtf16Changed
XUser XUserUnregisterforDeviceAssociationChanged

See also

XThread API reference