New issue
Advanced search Search tips

Issue 810490 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 810486
Owner: ----
Closed: Apr 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug



Sign in to add a comment

Potential issue in Skia's use of DiscardableSharedMemory

Project Member Reported by erikc...@chromium.org, Feb 8 2018

Issue description

Skia appears to use DiscardableSharedMemory on all platforms.

https://cs.chromium.org/chromium/src/skia/ext/SkDiscardableMemory_chrome.cc?type=cs&q=AllocateLockedDiscardableMemory&sq=package:chromium&l=40
"""
SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
  return new SkDiscardableMemoryChrome(
      base::DiscardableMemoryAllocator::GetInstance()
          ->AllocateLockedDiscardableMemory(bytes));
}
"""

But DiscardableSharedMemory is only implemented on Android.
"""
// Returns SUCCESS on platforms which do not support discardable pages.
DiscardableSharedMemory::LockResult LockPages(const SharedMemory& memory,
                                              size_t offset,
                                              size_t length) {
#if defined(OS_ANDROID)
  SharedMemoryHandle handle = memory.handle();
  if (handle.IsValid()) {
    int pin_result = ashmem_pin_region(handle.GetHandle(), offset, length);
    if (pin_result == ASHMEM_WAS_PURGED)
      return DiscardableSharedMemory::PURGED;
    if (pin_result < 0)
      return DiscardableSharedMemory::FAILED;
  }
#endif
  return DiscardableSharedMemory::SUCCESS;
}
"""
 
Labels: -Pri-3 Performance-Memory Pri-1

Comment 2 by hcm@chromium.org, Apr 9 2018

Cc: hcm@chromium.org vmp...@chromium.org enne@chromium.org
Components: -Internals>Skia Internals>Compositing
Skia only uses discardable memory when we're told... getting this over to the compositor team to review.

Comment 3 by enne@chromium.org, Apr 9 2018

Cc: ericrk@chromium.org
I'm not quite sure what you're getting at.  We use this discardable interface on all platforms, but it's backed by ashmem on Android and shared memory on other platforms.
Mergedinto: 810486
Status: Duplicate (was: Untriaged)
The root problem is that discardable shared memory is not regularly purged on Desktop [the implementation relies on OS memory pressure notifications, which have very different behaviors on different platforms. On macOS, it fires much too late]

Sign in to add a comment