openfl / openfl-native

[deprecated] OpenFL native backend
1 stars 1 forks source link

Repeatedly scaling a textfield eventually causes the text to flicker and makes Assets return null #74

Closed jgranick closed 6 years ago

jgranick commented 11 years ago

74 Issue by NickHolder,

Repeatedly scaling a textfield eventually causes the text to flicker, After flicker starts Assets.getBytes or Assets.getBitmapData return null

Can be reproduced with the below code, and a project with the openfl.svg icon in the assets folder.

Win7 64bit openfl-native 1.0.8 openfl-tools 1.0.10 openfl 1.0.6

Main.hx

package ;

import flash.display.Sprite;
import flash.events.Event;
import flash.Lib;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFormat;
import openfl.Assets;

class Main extends Sprite 
{

    var _textField:TextField;
    var _scaleVel:Float = 0.05;

    public function new() 
    {
        super();    

        var format = new TextFormat ("_sans", 20, 0x00FF00);

        _textField = new TextField();
        _textField.defaultTextFormat = format;
        _textField.text = "Test";
        _textField.x = 100;
        _textField.y = 100;

        Lib.current.stage.addChild( _textField );
        _textField.scaleY = 0.5;

        addEventListener( Event.ENTER_FRAME , onEnterFrame );

    }

    private function onEnterFrame(e:Event):Void 
    {
        _textField.scaleY += _scaleVel;

        if ( _textField.scaleY > 2 || _textField.scaleY < -2 ) 
        {
            _scaleVel = -_scaleVel;
            trace( Assets.getBytes( "assets/openfl.svg" ) );
        }
    }

    public static function main() 
    {
        Lib.current.addChild(new Main());
    }
}

application.xml

<?xml version="1.0" encoding="utf-8"?>
<project>
    <!-- NMML reference: https://gist.github.com/1763850 -->

    <!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
    <meta title="CPP_TextField" package="CPPTextField" version="1.0.0" company="Nick Holder" />

    <!-- output -->
    <app main="Main" file="CPPTextField" path="bin" />

    <window background="#ffffff" fps="60" />
    <window width="800" height="480" unless="mobile" />
    <window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />

    <!-- classpath, haxe libs -->
    <source path="src" />
    <haxelib name="openfl" />
    <haxelib name="actuate" />

    <!-- assets -->
    <icon path="assets/openfl.svg" />
    <assets path="assets" rename="assets" />

    <!-- optimize output
    <haxeflag name="-dce full" /> -->

</project>
jgranick commented 11 years ago

Comment by NickHolder:

This still seems to occur on: Win7 64bit openfl-native 1.1.2 openfl-tools 1.0.10 openfl 1.1.0

jgranick commented 11 years ago

Comment by NickHolder:

I've now tested this on Mac OSX 10.7.5 and Ubuntu 12.04 LTS with the same results (after running Haxelib upgrade).

jgranick commented 11 years ago

Comment by gunnbr:

I have the same problem. Was working on an in game menu and hit this. On the Mac, shortly after the text starts flickering, I see:

Persistent UI failed to open file file:///Users/gunnbr/Library/Saved%20Application%20State/com.example.menutest.savedState/window_1.data: Too many open files (24)

Then trying to load any more assets after that fails.