flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Wrap bitmaps for debugger with FLX_DEBUG so they don't appear in release build

Open T1mL3arn opened this issue 2 years ago • 8 comments

There are some bitmaps which are used only when FLX_DEBUG implies but aren't wrapped with this define. So they are included in release build inflating project size and aren't used by any code

If such behavior is considered a bug I will wrap other similar cases.

T1mL3arn avatar Jan 11 '24 07:01 T1mL3arn

My assumption is that these classes are only included if referenced in code, as they don't have the @:keep tag like other graphics do, therefore these already do not appear in release builds

Geokureli avatar Jan 11 '24 14:01 Geokureli

as they don't have the @:keep tag

I believe the problem is with @:bitmap - it embeds data no matter what.

See these html5 builds:

The first one is default release compilation, search GraphicMinimizeButton and you will see it is there. https://github.com/T1mL3arn/HaxeFlixel-Pong/commit/04dcf39ecfa502a021ee3be50439c37cee56babf

This one I made just now, with excluded bitmaps. Search GraphicMinimizeButton and there are only deletions. https://github.com/T1mL3arn/HaxeFlixel-Pong/commit/c827ffe1328124ce5c230ff82d42f954e1eb250d

T1mL3arn avatar Jan 11 '24 15:01 T1mL3arn

CI is failing because of the changes you made to the new classes, i dont see why you edited those classes

Geokureli avatar Jan 17 '24 03:01 Geokureli

CI is failing because of the changes you made to the new classes

Can you elaborate more why checks are failing? I see in log that it failed on HaxeFlixel/setup-flixel@v1 but it doesn't provide any details what's wrong and I also see that tests, demos, and snippets are all green. I am confused.

i dont see why you edited those classes

It's not possible to just wrap bitmap classes as they are - projects won't compile. So I had to figure out some minimum of changes that allows compilation in both debug and release modes.

Other ways to consider:

  • wrap debug things on the very top of FlxG, so none of them are available in release builds (e.g. users must then wrap FlxG.debugger in their code)
  • wrap each @:bitmap but not the types themselves, so bitmaps are not included and types are erased if user does dce or analyzer
  • ask Haxe to fix @:bitmap

T1mL3arn avatar Jan 17 '24 03:01 T1mL3arn

Screenshot_20240117-094221 Type not found: StatsGraph

Also i thought @:bitmap was a openfl/lime thing

Geokureli avatar Jan 17 '24 14:01 Geokureli

this was the change I originally requested. Not sure why you changed any of the other files, as those are outside the scope and also breaking changes.

this should prevent the images from being embedded in release, please verify this

Geokureli avatar Jan 17 '24 16:01 Geokureli

Sorry for late response.

Not sure why you changed any of the other file

To make it compile. This problem with embedded bitmaps goes beyond a module from the initial commit - there are quite enough such bitmaps.

T1mL3arn avatar Feb 03 '24 02:02 T1mL3arn

Are there any issues with these new changes? Can you verify that this prevents them from being embedded?

Geokureli avatar Feb 03 '24 17:02 Geokureli

@T1mL3arn ?

Can you verify that this prevents them from being embedded?

Geokureli avatar Feb 24 '24 15:02 Geokureli

Fixed via https://github.com/HaxeFlixel/flixel/pull/3077 I went a simpler route

Geokureli avatar Mar 12 '24 20:03 Geokureli