27 মার্চ, 2025 থেকে, আমরা AOSP তৈরি করতে এবং অবদান রাখতে aosp-main
এর পরিবর্তে android-latest-release
ব্যবহার করার পরামর্শ দিচ্ছি। আরও তথ্যের জন্য, AOSP-তে পরিবর্তনগুলি দেখুন।
ক্লায়েন্ট ফ্রেমবাফার ব্যবস্থাপনা
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
Android 13 দিয়ে শুরু করে, ক্লায়েন্ট কম্পোজিশনের সময় ব্যবহৃত নতুন ফ্রেমবাফারগুলি যখনই ডিসপ্লে রেজোলিউশন পরিবর্তন হয় তখন বরাদ্দ করা হয়। রেজোলিউশন পরিবর্তনের পর পরবর্তী অবৈধ চক্রে SurfaceFlinger দ্বারা এই বরাদ্দ করা হয়।
রেজোলিউশন সুইচের সময় ফ্রেমবাফার ব্যবস্থাপনা
নিম্নলিখিত দুটি পরিস্থিতির একটির কারণে রেজোলিউশন পরিবর্তন ঘটে:
একটি হটপ্লাগ ইভেন্ট , যা হার্ডওয়্যার কম্পোজার (HWC) দ্বারা সূচিত হয়, যা একটি বাহ্যিক ডিসপ্লে থেকে একটি ভিন্ন ডিফল্ট রেজোলিউশনে অদলবদল করার সময় ঘটে।
একটি হটপ্লাগ ইভেন্টের সময়, পুরানো ডিসপ্লে ডেটা ডিলোকেট করা হলে পুরানো ফ্রেমবাফারগুলির হ্যান্ডেলগুলি প্রকাশ করা হয়।
SurfaceFlinger দ্বারা শুরু করা একটি ডিসপ্লে মোড সুইচ, যা তখন ঘটে যখন ব্যবহারকারী ব্যবহারকারী সেটিংসের সাথে রেজোলিউশন পরিবর্তন করে, অথবা একটি অ্যাপ preferredDisplayModeId
দিয়ে রেজোলিউশন পরিবর্তন করে।
একটি ডিসপ্লে মোড স্যুইচ করার সময়, setActiveConfig
বা setActiveConfigWithConstraints
কল করার আগে বিদ্যমান ক্লায়েন্ট ফ্রেমবাফারগুলির হ্যান্ডেলগুলি SurfaceFlinger দ্বারা প্রকাশ করা হয়।
পুরানো এবং নতুন ফ্রেমবাফারগুলির জন্য পর্যাপ্ত মেমরি সংরক্ষণ করে না এমন ডিভাইসগুলিতে মেমরি ফ্র্যাগমেন্টেশনের মতো বিপর্যয়মূলক সমস্যাগুলি এড়াতে, এটি গুরুত্বপূর্ণ যে HWC পুরানো ফ্রেমবাফারগুলি ব্যবহার করা বন্ধ করে দেয় এবং নিম্নলিখিত ক্ষেত্রে দেখানো হিসাবে এই ফ্রেমবাফারগুলিতে কোনও হ্যান্ডেল প্রকাশ করে:
হ্যান্ডলগুলি প্রকাশ করার ফলে সারফেসফ্লিংগার পরবর্তী অবৈধ চক্রের সময় সঞ্চালিত নতুন ফ্রেমবাফারগুলির বরাদ্দের আগে ফ্রেমবাফার মেমরিকে সম্পূর্ণরূপে ডিলকেটেড করার অনুমতি দেয়।
ফ্রেমবাফার পরিচালনার জন্য সুপারিশ
HWC যদি সময়মতো পুরানো ফ্রেমবাফারগুলিতে হ্যান্ডেলগুলি প্রকাশ না করে, তবে নতুন ফ্রেমবাফার বরাদ্দ পুরানো ফ্রেমবাফার ডিলোকেশনের আগে ঘটে। বিভক্তকরণ বা অন্যান্য সমস্যার কারণে নতুন বরাদ্দ ব্যর্থ হলে এটি বিপর্যয়কর সমস্যা সৃষ্টি করতে পারে। আরও খারাপ, যদি HWC এই হ্যান্ডেলগুলিকে প্রকাশ না করে তবে একটি মেমরি লিক হতে পারে।
বিপর্যয়মূলক বরাদ্দ ব্যর্থতা এড়াতে, এই সুপারিশগুলি অনুসরণ করুন:
যদি নতুন ক্লায়েন্ট ফ্রেমবাফারগুলি প্রদান না করা পর্যন্ত HWC-কে পুরানো ক্লায়েন্ট ফ্রেমবাফারগুলি ব্যবহার করা চালিয়ে যেতে হয়, তাহলে পুরানো এবং নতুন উভয় ফ্রেমবাফারের জন্য যথেষ্ট মেমরি সংরক্ষণ করা এবং সম্ভবত ফ্রেমবাফার মেমরি স্পেসে ডিফ্র্যাগমেন্টেশন অ্যালগরিদম চালানো গুরুত্বপূর্ণ।
ফ্রেমবাফারগুলির জন্য একটি ডেডিকেটেড মেমরি পুল বরাদ্দ করুন যা বাকি গ্রাফিক বাফার মেমরি থেকে আলাদা। এটি গুরুত্বপূর্ণ কারণ ফ্রেমবাফারগুলির ডিললোকেশন এবং পুনঃবণ্টনের মধ্যে, একটি তৃতীয় পক্ষের প্রক্রিয়া গ্রাফিক্স মেমরি বরাদ্দ করার চেষ্টা করতে পারে। যদি একই গ্রাফিক্স মেমরি পুল ফ্রেমবাফার দ্বারা ব্যবহার করা হয় এবং যদি গ্রাফিক্স মেমরি পূর্ণ থাকে, তবে তৃতীয় পক্ষের প্রক্রিয়াটি একটি ফ্রেমবাফার দ্বারা পূর্বে বরাদ্দ করা গ্রাফিক্স মেমরি দখল করতে পারে, এইভাবে ফ্রেমবাফার পুনঃঅবস্থানের জন্য অপর্যাপ্ত মেমরি বা, সম্ভবত মেমরি স্পেসকে খণ্ডিত করে।
পরীক্ষা ফ্রেমবাফার ব্যবস্থাপনা
OEMগুলিকে তাদের ডিভাইসের জন্য রেজোলিউশন সুইচ জুড়ে সঠিক ক্লায়েন্ট ফ্রেমবাফার মেমরি পরিচালনার জন্য পরীক্ষা করার পরামর্শ দেওয়া হয়, যা নিম্নরূপ বর্ণনা করা হয়েছে:
হটপ্লাগ ইভেন্টের জন্য, আলাদা আলাদা রেজোলিউশন সহ দুটি ভিন্ন ডিসপ্লে আনপ্লাগ এবং পুনরায় সংযোগ করুন।
মোড সুইচের জন্য, ফ্রেমবাফার মেমরি আচরণ পরীক্ষা করার জন্য একটি মোড সুইচ শুরু করতে ModeSwitchingTestActivity
CTS যাচাইকারী পরীক্ষাটি ব্যবহার করুন। এই পরীক্ষাটি দৃশ্যত সমস্যা সনাক্ত করতে পারে যা প্রোগ্রামগতভাবে সনাক্ত করা কঠিন।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Client framebuffer management\n\nStarting with Android 13, new framebuffers, used during\n[client](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl#113)\ncomposition, are allocated whenever the display resolution changes. This\nallocation is performed by SurfaceFlinger on the next *invalidate* cycle\nafter a resolution change.\n\nFramebuffer management during resolution switches\n-------------------------------------------------\n\nResolution changes occur due to one of the following\ntwo scenarios:\n\n- A [hotplug event](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl#41),\n initiated by Hardware Composer (HWC), which occurs when swapping from one external\n display to a different external display that has a different default resolution.\n\n During a hotplug event, the handles to the old framebuffers are released\n when the old display data is deallocated.\n- A display mode switch initiated by SurfaceFlinger, which occurs when the\n user changes the resolution with [user settings](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/core/java/android/hardware/display/DisplayManager.java#1209),\n or an app changes the resolution with [`preferredDisplayModeId`](https://developer.android.com/reference/android/view/WindowManager.LayoutParams#preferredDisplayModeId).\n\n During a display mode switch, the handles to existing client framebuffers\n are released by SurfaceFlinger before calling [`setActiveConfig`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl#550)\n or [`setActiveConfigWithConstraints`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl#577).\n\nTo avoid catastrophic problems, such as memory fragmentation, on devices that\ndon't reserve enough memory for the old and new framebuffers, it's critical\nthat HWC ceases to use the old framebuffers and releases any\nhandles to these framebuffers as shown in the following cases:\n\n- For hotplug events, immediately before calling [`onHotplug`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl#41).\n\n- For mode switches, immediately after the call to [`setActiveConfig`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl#550)\n or [`setActiveConfigWithConstraints`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl#577).\n\nReleasing the handles allows the framebuffer memory to be fully deallocated\nprior to the allocation of new framebuffers that SurfaceFlinger performs\nduring the next *invalidate* cycle.\n\n### Recommendations for framebuffer management\n\nIf HWC doesn't release handles to old framebuffers in time,\nthe new framebuffer allocation takes place before the old framebuffer\ndeallocation. This can cause catastrophic problems when the new allocation fails\ndue to fragmentation or other issues. Even worse, if\nHWC doesn't release these handles at all, a memory leak can\noccur.\n\nTo avoid catastrophic allocation failures, follow these recommendations:\n\n- If HWC needs to continue using the old client framebuffers until the new\n client framebuffers are provided, then it's critical to reserve enough memory\n for both the old and new framebuffers, and possibly run defragmentation\n algorithms on the framebuffer memory space.\n\n- Allocate a dedicated memory pool for the framebuffers that's separate from\n the rest of the graphic buffer memory. This is important because between\n deallocation and reallocation of the framebuffers, a third-party process can\n attempt to allocate graphics memory. If the same graphics memory pool is\n used by the framebuffer and if the graphics memory is full, the third-party\n process can occupy the graphics memory previously allocated by a framebuffer,\n thus leaving insufficient memory for the framebuffer reallocation or, possibly\n fragmenting the memory space.\n\nTest framebuffer management\n---------------------------\n\nOEMs are advised to test for proper client framebuffer memory management across\nresolution switches for their device, described as follows:\n\n- For hotplug events, simply unplug and reconnect two different displays with\n different resolutions.\n\n- For mode switches, use the [`ModeSwitchingTestActivity`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/apps/CtsVerifier/src/com/android/cts/verifier/tv/display/ModeSwitchingTestActivity.java;l=47-53;drc=c80d948aff1e7df5c2dc0ddba0d1cd63a90e4d9c) CTS\n Verifier test to initiate a mode switch for testing framebuffer memory behavior.\n This test can visually identify problems that are hard to detect\n programmatically."]]