HaxeFlixel / HaxeFlixel/flixel-addons

FlxPieDial leak

Open
#484 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haxe
Stars
196
Forks
175
PR merge metrics
No merged PRs in 30d

Description

Haxe version: 4.3.7
Flixel version: 6.2.0 (dev)
Flixel addons version: 4.0.1
OpenFL version: 9.5.1
Lime version: 8.3.1
Affected targets: Windows (and other platforms)

For some reason, FlxPieDial gives point/rect leak, which is most likely due to constant appearance of new graphics. It seems to be related to graphics cache via FlxG.bitmap, but every time state is switched, it doesn't find graphics from cache and creates a new one

Here's tests:

import flixel.FlxG;
import flixel.addons.display.FlxPieDial;
import flixel.FlxState;

class TestStateA extends FlxState
{
  var pie:FlxPieDial;

	override function create():Void {
		FlxG.camera.bgColor = 0xFF81FFA4;
		
		add(pie = new FlxPieDial(200, 200, 40, 0xFFFFFFFF, 36, CIRCLE));
		pie.amount = 0.5; //just to see pie
		super.create();
	}

	override function update(elapsed:Float):Void {
		if(FlxG.keys.justPressed.ENTER)
			FlxG.switchState(TestStateB.new);

		super.update(elapsed);
	}
}

class TestStateB extends FlxState
{
  //just empty state
	override function create():Void {
		FlxG.camera.bgColor = 0xFFFF8181;
		super.create();
	}

	override function update(elapsed:Float):Void {
		if(FlxG.keys.justPressed.ENTER)
			FlxG.switchState(TestStateA.new);

		super.update(elapsed);
	}
}

Either make graphics persist, or somehow try to fix finding graphics by key, I honestly don't know how to do it. Maybe Im doing something wrong?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided TestStateA/TestStateB reproduction and inspect FlxPieDial together with the FlxG.bitmap cache behavior. Track graphics and point/rect allocations while switching states repeatedly. Done means repeated switches no longer create an accumulating leak, with graphics reused or correctly found through the cache.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.