Skip to content

Conversation

@suhailmalik07
Copy link

@suhailmalik07 suhailmalik07 commented Dec 26, 2025

Describe your changes

Instead of creating new SpriteSheet on loading, Now it'll check if that SpriteSheet already exists, if it does use and fill it otherwise create new.

Let me know if needs more details or other issues in the PR.

Issue ticket number and link

Currently if SpriteSheet is partially deleted by android/ios partial memory cleanup. Reloading it again loads only missing sprites to a new SpriteSheet and marks it as full but it's not full. So If the cleanup happens again some sprites will be missed an not loaded again even after multiple tries.

Example.
Assume `p.plist` contains {`a.png`, `b.png`}

on first fresh load.
SpriteSheet{P}
  full: true
  _spriteFrames: {a.png, b.png}


first cleanup, let's assume a.png is removed
SpriteSheet{P}
  full: false
  _spriteFrames: {b.png}

If we load it again, current SpriteSheet will gets replaced, and it only loads missing png and marks it full.
SpriteSheet{P}
  full: true
  _spriteFrames: {a.png}


`b.png` will still be usable as SpriteFrameCache stores name to sprite.
but after second cleanup, let's assume `b.png` gets cleaned up. 
`p.plist` will not get loaded again as it's already full and `b.png` will not be found as as `SpriteSheet{P}` and cache doesn't contains it anymore.

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

@suhailmalik07 suhailmalik07 force-pushed the sprite-sheet-creation-fix branch 3 times, most recently from f5e07f7 to 3742cda Compare December 26, 2025 19:32
@suhailmalik07 suhailmalik07 force-pushed the sprite-sheet-creation-fix branch from 3742cda to 35cb502 Compare December 26, 2025 19:33
@suhailmalik07 suhailmalik07 marked this pull request as ready for review December 26, 2025 19:33
@rh101
Copy link
Contributor

rh101 commented Dec 27, 2025

Should this be targeting the release/2.x branch instead?

@halx99
Copy link
Collaborator

halx99 commented Dec 28, 2025

/clang-format

@axmol-bot
Copy link
Collaborator

👋 @halx99 Command /clang-format received. Running code formatting, please wait...

@axmol-bot
Copy link
Collaborator

✅ Formatting completed and changes have been committed to the PR branch: sprite-sheet-creation-fix.
@halx99 please refresh to see the latest code.

@halx99 halx99 changed the title fix sprite sheet creation logic Fix sprite sheet creation logic Dec 28, 2025
@halx99 halx99 added the bug Something isn't working label Dec 28, 2025
@halx99 halx99 added this to the 2.11.1 milestone Dec 28, 2025
halx99 pushed a commit that referenced this pull request Dec 31, 2025
- Changed SpriteSheet loading logic to check if a sheet already exists.
- If found, reuse and fill missing sprites instead of creating a new sheet.
- Prevents incorrect `full` flag when Android/iOS partial memory cleanup removes some sprites.
- Ensures subsequent reloads correctly restore all frames without missing assets.

refer: #2978
@halx99
Copy link
Collaborator

halx99 commented Dec 31, 2025

I merge this PR patch to release/2.x manually, Thanks for your PR @suhailmalik07

@halx99 halx99 closed this Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants