Stay organized with collections
Save and categorize content based on your preferences.
Added in ARCore 1.17.0
Most apps only need to buffer a single camera frame for rendering. However,
ARCore also supports buffering multiple camera frames in a fixed-size
round-robin texture queue.
Apps with a multithreaded rendering pipeline can use buffering to help improve
rendering performance. Buffering can also help apps render frames at a more
consistent frame rate, which can reduce visual stutter caused by
slow UI rendering.
Preconditions
Camera image buffering becomes enabled under any of the following conditions:
When one or more ARCore features that require internal buffering are
enabled. Currently this includes these features:
Augmented Images
Augmented Faces
On certain ARCore supported devices that require internal buffering to
operate correctly.
Determine whether frame delay is enabled
To determine whether a given device and AR session have frame buffering (also
known as frame delay) enabled, use the adb logcat output:
# Camera frame buffering is turned off when frame delay is zero.adblogcat|grep'Update Frame Delay'…Inative:session.cc:3141UpdateFrameDelayto0frames.
# Camera frame buffering is turned on when frame count is non-zero.# Note: The size of the buffer can vary over time.adblogcat|grep'Update Frame Delay'…Inative:session.cc:3141UpdateFrameDelayto6frames.……Inative:session.cc:3141UpdateFrameDelayto4frames.……Inative:session.cc:3141UpdateFrameDelayto2frames.
Memory
Each additional camera frame buffered increases memory utilization. For example,
a 1080p texture consumes approximately 6 MB of memory (obtained by multiplying a
resolution of 1920 x 1080 by three bytes RGB data per pixel).
Performance considerations
Using multiple camera frames is not guaranteed to decrease variability of
frame rates, and using a multithreaded rendering pipeline is not guaranteed to
provide better performance in all circumstances. The following factors affect
real-world performance:
The app rendering pipeline
The app threading model
The device CPU architecture
The operating system scheduling system
If your app is unable to take advantage of additional camera frames, there is no
performance advantage in using more than one texture.
Enable buffering
To instruct ARCore which textures to use to buffer incoming camera frames, use
ArSession_setCameraTextureNames(ids) to provide an array of one or more texture IDs.
This function is called only after session creation, and is called usually only
once.
During each call to ArSession_update(), ARCore overwrites the next texture in
the queue in a round-robin sequence. If your app sets only a single texture ID,
the same texture will be overwritten each time.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eARCore's camera frame buffering, enabled by default for some features or manually by the app, enhances rendering by storing multiple camera frames.\u003c/p\u003e\n"],["\u003cp\u003eBuffering improves rendering performance and reduces stutter, especially in apps with multithreaded rendering pipelines, but it increases memory usage.\u003c/p\u003e\n"],["\u003cp\u003eARCore dynamically adjusts the buffer size, and the \u003ccode\u003eadb logcat\u003c/code\u003e output reveals whether frame delay (buffering) is enabled and the current buffer size.\u003c/p\u003e\n"],["\u003cp\u003ePerformance gains from buffering depend on factors like the app's rendering pipeline, threading model, device, and OS, so thorough testing on target devices is crucial.\u003c/p\u003e\n"],["\u003cp\u003eApps can enable buffering and manage textures through specific ARCore functions, ensuring the efficient utilization of camera frames for rendering.\u003c/p\u003e\n"]]],["ARCore 1.17.0 supports buffering multiple camera frames in a texture queue to enhance rendering performance, particularly for multithreaded pipelines. Buffering is enabled by providing multiple texture IDs via `ArSession_setCameraTextureNames(ids)`, or when certain ARCore features like Augmented Images or Faces are active, or on some specific ARCore devices. Frame delay, indicating active buffering, can be monitored via `adb logcat`. Each additional buffered frame increases memory use. Apps can use `ArFrame_getCameraTextureName()` to get the texture ID. The frame rate improvement depends on device and app design.\n"],null,["# Buffering camera frames\n\n**Added in ARCore 1.17.0**\n\nMost apps only need to buffer a single camera frame for rendering. However,\nARCore also supports buffering multiple camera frames in a fixed-size\nround-robin texture queue.\n\nApps with a multithreaded rendering pipeline can use buffering to help improve\nrendering performance. Buffering can also help apps render frames at a more\nconsistent frame rate, which can reduce visual stutter caused by\n[slow UI rendering](https://developer.android.com/topic/performance/vitals/render).\n\nPreconditions\n-------------\n\nCamera image buffering becomes enabled under *any* of the following conditions:\n\n1. **When enabled by the app** by calling [`ArSession_setCameraTextureNames(ids)`](/ar/reference/c/group/session#arsession_setcameratexturenames)\n with multiple texture IDs.\n\n2. **When one or more ARCore features that require internal buffering are\n enabled**. Currently this includes these features:\n\n - Augmented Images\n - Augmented Faces\n3. **On certain ARCore supported devices** that require internal buffering to\n operate correctly.\n\nDetermine whether frame delay is enabled\n----------------------------------------\n\nTo determine whether a given device and AR session have frame buffering (also\nknown as frame delay) enabled, use the `adb` logcat output: \n\n # Camera frame buffering is turned off when frame delay is zero.\n adb logcat | grep 'Update Frame Delay'\n ... I native : session.cc:3141 Update Frame Delay to 0 frames.\n\n # Camera frame buffering is turned on when frame count is non-zero.\n # Note: The size of the buffer can vary over time.\n adb logcat | grep 'Update Frame Delay'\n ... I native : session.cc:3141 Update Frame Delay to 6 frames.\n ...\n ... I native : session.cc:3141 Update Frame Delay to 4 frames.\n ...\n ... I native : session.cc:3141 Update Frame Delay to 2 frames.\n\nMemory\n------\n\nEach additional camera frame buffered increases memory utilization. For example,\na 1080p texture consumes approximately 6 MB of memory (obtained by multiplying a\nresolution of 1920 x 1080 by three bytes RGB data per pixel).\n\nPerformance considerations\n--------------------------\n\n| **Caution:** If you decide to use a multithreaded pipeline, make sure to test production builds (not debug builds of your app) on the same devices that your users will use.\n\nUsing multiple camera frames is not guaranteed to decrease variability of\nframe rates, and using a multithreaded rendering pipeline is not guaranteed to\nprovide better performance in all circumstances. The following factors affect\nreal-world performance:\n\n- The app rendering pipeline\n\n- The app threading model\n\n- The device CPU architecture\n\n- The operating system scheduling system\n\nIf your app is unable to take advantage of additional camera frames, there is no\nperformance advantage in using more than one texture.\n\nEnable buffering\n----------------\n\nTo instruct ARCore which textures to use to buffer incoming camera frames, use\n[`ArSession_setCameraTextureNames(ids)`](/ar/reference/c/group/session#arsession_setcameratexturenames) to provide an array of one or more texture IDs.\nThis function is called only after session creation, and is called usually only\nonce.\n\nDuring each call to [`ArSession_update()`](/ar/reference/c/group/session#arsession_update), ARCore overwrites the next texture in\nthe queue in a round-robin sequence. If your app sets only a single texture ID,\nthe same texture will be overwritten each time.\n\nUse [`ArFrame_getCameraTextureName()`](/ar/reference/c/group/frame#arframe_getcameratexturename) to determine the texture ID associated\nwith the current frame."]]