haxeui / haxeui-flixel

The Flixel backend of the HaxeUI framework
MIT License
45 stars 13 forks source link

Creating an absurdly long label causes invalid bitmap data #15

Closed greysondn closed 5 years ago

greysondn commented 5 years ago

image

ArgumentError: Error #2015: Invalid BitmapData.
        at flash.display::BitmapData/get width()
        at flixel.util::FlxDestroyUtil$/disposeIfNotEqual()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\util\FlxDestroyUtil.hx:96]
        at flixel.graphics.frames::FlxFrame/paint()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\graphics\frames\FlxFrame.hx:299]
        at flixel::FlxSprite/updateFramePixels()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\FlxSprite.hx:937]
        at flixel::FlxSprite/calcFrame()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\FlxSprite.hx:913]
        at flixel::FlxSprite/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\FlxSprite.hx:650]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel.group::FlxTypedSpriteGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxSpriteGroup.hx:213]
        at haxe.ui.backend::ComponentBase/draw()[C:\HaxeToolkit\haxe\lib\haxeui-flixel\git\haxe\ui\backend\ComponentBase.hx:368]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel.group::FlxTypedSpriteGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxSpriteGroup.hx:213]
        at haxe.ui.backend::ComponentBase/draw()[C:\HaxeToolkit\haxe\lib\haxeui-flixel\git\haxe\ui\backend\ComponentBase.hx:368]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel.group::FlxTypedSpriteGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxSpriteGroup.hx:213]
        at haxe.ui.backend::ComponentBase/draw()[C:\HaxeToolkit\haxe\lib\haxeui-flixel\git\haxe\ui\backend\ComponentBase.hx:368]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel.group::FlxTypedSpriteGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxSpriteGroup.hx:213]
        at haxe.ui.backend::ComponentBase/draw()[C:\HaxeToolkit\haxe\lib\haxeui-flixel\git\haxe\ui\backend\ComponentBase.hx:368]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel.group::FlxTypedSpriteGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxSpriteGroup.hx:213]
        at haxe.ui.backend::ComponentBase/draw()[C:\HaxeToolkit\haxe\lib\haxeui-flixel\git\haxe\ui\backend\ComponentBase.hx:368]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel.group::FlxTypedGroup/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\group\FlxGroup.hx:185]
        at flixel::FlxState/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\FlxState.hx:70]
        at flixel::FlxGame/draw()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\FlxGame.hx:859]
        at flixel::FlxGame/onEnterFrame()[C:\HaxeToolkit\haxe\lib\flixel\git\flixel\FlxGame.hx:551]

Created a simple project to demonstrate this. Target flash to trigger.

eli-2.zip

MSGhero commented 5 years ago

Flash has a hard limit on bmd size, 8191 pixels w or h and 16,777,215 total pixels. So this doesn’t have anything to do with flixel.

greysondn commented 5 years ago

todayIlearned

I'm having a devil of a time converting that from an ever-expanding scrollback into a limited buffer (which is the traditional model here). The issue with mouse events still hasn't been resolved AFAICT, so label remains my dumping ground for displaying a text scrollback for now.

Scrolling to a fixed point in that on output is proving surprisingly hard. (It was surprisingly easy when output was scrolled to after adding more content.) I'm at the point where I'm thinking I'm stuck generating a new label when it reaches too large a size (and keeping a scrollback buffer in an array) for now as a workaround, but would encourage you to continue work on this.

I'm also at the point where publication platform is about to get a hard poke to implement HTML5 support already :o)


scrolling to a fixed point in that

I can tell I'm disorganized and not awake, my apologies.

So I tried to implement it as a limited buffer, where I just destroy part of the text (at the start of the buffer) when it gets too large. Standard faire probably expressed in an awkward way.

It seems that labels maintain their height even when content changes. Something is screwy, anyway. Trying to scroll on that to a fixed point in the text is proving all but impossible. I've tried the math several ways around and I'm convinced either it's impossible or (as is often the case at the end of the day) I'm an idiot.

A helper for scrolling to a specific point in text would be immeasurably useful, though. I'm having a devil of a time estimating exactly where a character is in spatial terms.

MSGhero commented 5 years ago

Oh yeah, definitely hitting the Flash pixel limit for bmds. On other targets, the updates take an extremely long time and essentially freeze the game.

Regarding your other point, you can use the TextLineMetrics or character boundaries of the internal TextField (myFlxText.textField.getCharBoundaries), which gives you where that specific character is laid out. I'm closing this issue, but feel free to ask further about that on Discord or something.