Skip to content

Investigate PAGE_SCALE usage and over-allocation #52

@nchapman

Description

@nchapman

Problem

PAGE_SCALE is used to allocate ION memory buffers but appears to massively over-allocate:

480p mode (PAGE_SCALE=3):

  • Allocates: 1920×1440 = 5.27 MB
  • Actually uses: max ~800×720 = 1.1 MB
  • Waste: ~4 MB (76%)

560p mode (PAGE_SCALE=2):

  • Allocates: 1504×1120 = 3.21 MB
  • Actually uses: max ~1000×864 = 1.7 MB
  • Waste: ~1.5 MB (47%)

Current Behavior

#define PAGE_SCALE (is_560p ? 2 : 3)
#define PAGE_WIDTH (FIXED_WIDTH * PAGE_SCALE)
#define PAGE_HEIGHT (FIXED_HEIGHT * PAGE_SCALE)
#define PAGE_SIZE (PAGE_PITCH * PAGE_HEIGHT)

Buffer is allocated at PAGE_SIZE but surfaces are created at actual needed dimensions (vid.width × vid.height).

Questions

  1. Why such large over-allocation? Original MinUI comment says "to support various scaling operations" but what specifically?
  2. Is PAGE_WIDTH/HEIGHT ever used directly? Only trimuismart appears to create surfaces at PAGE dimensions
  3. Can we reduce PAGE_SCALE? Would PAGE_SCALE=2 for 480p and PAGE_SCALE=1.5 for 560p work?
  4. Is this legacy code? Maybe needed for older rendering paths that have since been removed?

Investigation Needed

  • Check if reducing PAGE_SCALE breaks any scaling modes (native/aspect/fullscreen)
  • Test with maximum scale factors (6x for GB 160×144)
  • Verify no buffer overruns with tighter allocation
  • Check original MinUI history for why these values were chosen

Impact

Not critical but could save 2-3 MB of ION memory per device, potentially improving stability on memory-constrained units.

References

  • workspace/all/common/api.h:24-31 - PAGE definitions
  • workspace/miyoomini/platform/platform.h:155 - PAGE_SCALE override
  • workspace/miyoomini/platform/platform.c:303 - Buffer allocation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions