Application crash (Black screen) on android with openfl legacy

When compiling with dev openfl and lime (git versions) I have this error:

Called from ApplicationMain::main ApplicationMain.hx line 146
Called from ApplicationMain::create ApplicationMain.hx line 59
Called from lime.app.Application::exec lime/app/Application.hx line 218
Called from lime._backend.native.NativeApplication::exec lime/_backend/native/NativeApplication.hx line 104
Called from lime._backend.native.NativeApplication::handleRenderEvent lime/_backend/native/NativeApplication.hx line 259
Called from lime.app.Event_Void_Void::dispatch lime/app/Event.hx line 139
Called from *::_Function_2_1 lime/app/Application.hx line 107
Called from lime.app.Application::render lime/app/Application.hx line 675
Called from openfl.display.Stage::render openfl/display/Stage.hx line 1074
Called from openfl.display.DisplayObjectContainer::__broadcast openfl/display/DisplayObjectContainer.hx line 645
Called from openfl.display.DisplayObject::__broadcast openfl/display/DisplayObject.hx line 967
Called from openfl.events.EventDispatcher::__dispatchEvent openfl/events/EventDispatcher.hx line 463
Called from flixel.FlxGame::onEnterFrame flixel/FlxGame.hx line 506
Called from flixel.FlxGame::draw flixel/FlxGame.hx line 808
Called from flixel.FlxCamera::render flixel/FlxCamera.hx line 401
Called from openfl.display.Tilesheet::drawTiles openfl/display/Tilesheet.hx line 194
Called from openfl.display.Graphics::drawTiles openfl/display/Graphics.hx line 856

with a “Null object reference” popup on windows. Don’t have any error when compiled with openfl 3.3.3 and lime 2.6.2. So just check you didn’t break anything in Graphics.hx…

I made some changes here yesterday that are still in-progress, try pulling from OpenFL one more time, I think I fixed what was causing this :slight_smile:

OK. I performed the checkout and it works now.
One question I have concerning the getPixel() and getPixel32() methods. According to the openfl API, it is supposed to return UInt values: http://www.openfl.org/documentation/api/openfl/display/BitmapData.html
However, in the code source of openfl 3.3.3 and git version, it appears to return Int values. Is there a good reason for that?
Because as a consequence, doing some test like:

if (bitmapdata.getPixel32(x,y) == 0xFF000000) 

results in an error when trying to compiled for flash:

Comparison of Int and UInt might lead to unexpected results

It works for cpp target though…

That’s caused by Flash returning UInt values, at one point, we forced all the UInt values in Flash to be Int values, so that we could avoid these types of headaches. I think this might work on Flash:

if (bitmapData.getPixel32 (x, y) == new UInt (0xFF000000))
1 Like

Text works for me only with -Dlegacy, otherwise even regular text (TextFieldType.DYNAMIC) field doesn’t show up.
And my test app crashes with -Dhybrid.
Are there any other dependencies, I might missed?

So “AddingText” and “PiratePig” show no text for you?

which version of lime and openfl are you using?
Can you prompt

haxelib list

in a console and copy the result here?

I’ve just reinstalled haxe and openfl/lime, everything is latest version.

actuate: [1.8.6]
box2d: [1.2.3]
extension-amazonads: [0.0.2]
extension-multiads: [1.0.2]
extension-share: [2.1.0]
format: [3.2.0]
hxcpp: [3.2.102]
layout: [1.2.1]
lime-samples: [2.6.0]
lime: [2.6.2]
openfl-admob: [1.4.1]
openfl-gps-lib: [1.0.4]
openfl-samples: [3.3.0]
openfl: [3.3.3]
roxlib: [1.1.3]
svg: [1.0.8]
swf: [2.0.2]

Give me 10 minutes, I’ll try AddingText and PiratePig.

Ok, AddingText works for me.
Looks like, font file and font-embeding are required with new OpenFL. Thank you!

And entering Cyrillic text is working now, a bit buggy, but working! :smiley:

I have some new issue with openfl next. This time, it concerns TextField.

Given the following code:

var randtext:String = "Facilisis nonummy vivamus faucibus, pretium augue tincidunt pede ac laoreet hendrerit, fermentum nibh in pede volutpat in sed, lacus sit ultrices felis, feugiat amet ac augue tellus blandit venenatis.\nAuctor vitae malesuada massa id dictumst, sollicitudin quis ut.";
		
var format:TextFormat = new TextFormat ("prototype_font", 26, 0xFFFFFF);
format.align = TextFormatAlign.CENTER;
		
var textField:TextField = new TextField();
textField.defaultTextFormat = format;
textField.width = 450;
textField.height = 700;
textField.wordWrap = true;
textField.text = randtext;
		
addChild(textField);

Here is what I get:

As you can see, line 5 is shifted to the right (whith the consequence of it beeing truncated).

This bug appears only on certain conditions. So if you change the font, the font size or the text content, it might or might not appear… (usually, if you test different font size with a multiline text content, you will see it appear for some of the font size tested)

The font used in this example is this one: http://www.1001freefonts.com/prototype.font in case you want to reproduce the issue

Got it :smile:

1 Like

Still having this “word wrap” issue on android and windows with latest public versions of openfl (3.3.6) and lime (2.6.5).

It’s working here:

package;


import openfl.display.Sprite;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.text.TextFormatAlign;


class Main extends Sprite {
	
	
	public function new () {
		
		super ();
		
		var randtext:String = "Facilisis nonummy vivamus faucibus, pretium augue tincidunt pede ac laoreet hendrerit, fermentum nibh in pede volutpat in sed, lacus sit ultrices felis, feugiat amet ac augue tellus blandit venenatis.\nAuctor vitae malesuada massa id dictumst, sollicitudin quis ut.";
		
		var format:TextFormat = new TextFormat ("prototype_font", 26, 0xFF0000);
		format.align = TextFormatAlign.CENTER;
		
		var textField:TextField = new TextField();
		textField.defaultTextFormat = format;
		textField.width = 450;
		textField.height = 700;
		textField.wordWrap = true;
		textField.text = randtext;
		
		addChild(textField);
		
	}
	
	
}

(before the above commit I did see it wrapping improperly like your screen)

Well I don’t really understand, I just retested it on windows (in order to make a screenshot) and now it works (but I tested it 1h ago with the exact same conf and it didn’t)…I probably forgot the -clean flag in my first command, which might explain. I don’t see any other explanation…
On android I still have the bug though (line 6):

I use the exact same code as you (exept the font color wich I set to black rather than red) with openfl next version 3.3.6 and lime 2.6.5
and I compiled with the lime test android -Dnext -clean command (the -Dnext flag is probably not necessary as I think openfl, unlike haxeflixel, use openfl next by default. Right?)

Oh and I tested with openfl legacy on windows and I don’t even have the textefield that display (full white screen)… without any error in the console: lime test windows -Dlegacy -clean -debug

I tried on Android and got an empty screen. I realized I was not using the right font name. I changed “prototype_font” to “Prototype” and now it looks correct on Windows and Android for me :slight_smile:

well I have this in my project.xml file:

<assets path="Assets" rename="assets">
	<font path="fonts/Prototype.ttf" id="prototype_font" />
</assets>

So using prototype_font as a name should be ok for me. right?

Whatever, on android it do not work as expected (word wrap issue) and on windows with openfl legacy, the text do not display (not tested on android with legacy yet)

Try using the font name (“Prototype”) or Assets.getFont ("prototype_font").fontName

Ok you are right, using “Prototype” as a font name, this works… (both on android with openfl next and windows with openfl legacy) :smile:
How can i change the name of an asset then? (In my haxeflixel projects, I have fonts with strange names or sometimes I just want to chnage a font without having to change its name everywhere it occurs in my code. So I make intensive use of the <font path="fonts/realname.ttf" id="myname" /> tag in my project.xml file…

And what is strange is that, on android, when the asset font is not found, it looks like it fall back to a default font with word wrap issue whereas on windows with legacy it simply do not display the text… Would be good that in both cases, it fall back to a default font without display issues (like on windows with openfl next) :wink:

On my device, it falls back to nothing. I guess the default font name used doesn’t exist on this device?

Using an asset ID works with openfl.Assets, so getFont (id).fontName should work if you want to use this :slight_smile:

Tested with

var format:TextFormat = new TextFormat(Assets.getFont("prototype_font").fontName, 26, 0x000000);

and that do not work (still have the word wrap issue on android). The only way to have it work correctly for now is by directly using the fontname (ie: new TextFormat("Prototype", 26, 0x000000) ) so the asset ID is not working