Latest Android FireFox has performance issues with OpenFl based applications

Hey Folks!

Recently I accidentally upgraded Android’s FireFox to the latest 80 version. Yeah that piece
of *#@p where Mozilla decided to change everything. Apparently they changed even more than you
might think.
FireFox on Android always wasn’t my #1 choice since the performance was always way behind Chrome.

Usually an OpenFl game utilizing the Starling port and thus WebGl 2.0 runs at the full 60fps on
Chrome versus something around 40-50 on FireFox.

But with the latest FireFox suddenly the framerate dropped to useless 5 fps. Yeah you read right! Five!

Of course my initial thought was that my game was too demanding on the GFX side - though that wouldn’t
explain why the framerate has been way better before.

So I created a minimalistic test application with allow-high-dpi set to true, which doesn’t do much
beside utilizing the whole browser window and displaying a simple quad.

The result: the same freaking 5 fps again!

Of course I’m a little worried now since this makes the games effectively unplayable on FireFox and
I’m really wondering if anyone in here is experiencing the same?
Interestingly I just can replicate the issue with OpenFl based WebGl 2.0 games - others created using
pixi.js or the like don’t seem to suffer the same. Is there something inside OpenFl’s renderer which
needs modification to compensate for the new FireFox?

Here’s the code for the aforementioned minimalistic test:

Main.hx

package;

import openfl.display.Sprite;
import openfl.events.Event;
import openfl.Lib;
import openfl.display.StageScaleMode;
import openfl.geom.Rectangle;
import openfl.geom.Matrix;

import starling.core.Starling;
import flash.display3D.Context3DRenderMode;

class Main extends Sprite
{
	private var mStarling:Starling;
	private static var sw:Float = 0;
	private static var sh:Float = 0;

	public function new()
	{
		super();
		addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

	}
	private function onAddedToStage(event:Dynamic):Void
	{
		removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		stage.scaleMode = StageScaleMode.NO_SCALE;
		start();
	}
	
	private function start():Void
	{
		sw = Lib.application.window.width * stage.window.scale;
		sh = Lib.application.window.height * stage.window.scale;

		var rect:Rectangle = new Rectangle(0, 0, 0, 0);
		rect.width = sw;
		rect.height =  sh; trace(rect);
		mStarling = new Starling(Test, stage, rect, null, Context3DRenderMode.AUTO, "auto");

		mStarling.addEventListener(starling.events.Event.ROOT_CREATED, function():Void
		{
			var game:Test = cast(mStarling.root, Test);

			game.init();
		});

		mStarling.stage.stageWidth = Std.int(sw);
		mStarling.stage.stageHeight = Std.int(sh);
		mStarling.start();
	}
}

Test.hx

package;

import starling.core.Starling;
import starling.display.Sprite;
import starling.display.Sprite3D;
import starling.display.Stage;
import starling.display.Quad;

@:keep class Test extends Sprite
{
	public function new()
	{
		super();
	}
	
	public function init():Void
	{
		Starling.current.showStats = true;

		var sprite3D = new Sprite3D();
		var quad:Quad = new Quad(200, 200, 0xff0000);
		sprite3D.addChild(quad);
		sprite3D.x = stage.stageWidth / 2 - 100;
		sprite3D.y = stage.stageHeight / 2-100;
		sprite3D.rotationX = 45 * Math.PI / 180;
		addChild(sprite3D);
	}
}

project.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="FireFoxStarling" package="FireFoxStarling" version="1.0.0" company="" />
	
	<!-- output -->
	<app main="Main" file="FireFoxStarling" path="bin" />
	
	<window background="#103860" fps="60" />
	<window width="640" height="480" unless="mobile" />
	<window width="0" height="0" resizable="true" fps="60" if="html5" />
	<window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />
	<window allow-high-dpi="true" />
	
	<!-- classpath, haxe libs -->
	<source path="src" />
	<haxelib name="openfl" />
	<haxelib name="actuate" />
	<haxelib name="starling" />
	
	<!-- assets -->
	<icon path="assets/openfl.svg" />
	<assets path="assets/img" rename="img" />
	
	<!-- optimize output
	<haxeflag name="-dce full" /> -->
	<haxeflag name="--no-traces" if="final" />
</project>
1 Like

Does openfl test html5 -Dwebgl1 make a difference in performance?

Unfortunately no - I already tried that. After a lot of research I found out that I
need to set the webgl.enable-surface-texture option in FireFox’s about:config menu to true.
Apparently this option has always been enabled - or not been an option at all - with previous
versions of FireFox and got disabled because of random crashes with some particular
Android devices.
After activating it I get a fps (highly fluctuating though) of almost 60fps. I can’t
remember exactly but I think it has always been no rock-solid 60fps as with Chrome.

Of course it’s not an option to force users to activate that option. I think there
are some plans on Mozilla’s side to reactivate that feature - not sure though.

Do you think there’s anything which can be done on OpenFL’s side to work around that?
As I mentioned in my previous post the performance hit with other WebGL based games
wasn’t as dramatic - I can’t tell you where the difference is though.

In my experience over the last year or so, OpenFL performance in Firefox on Android has always been halfway decent, but noticeably slower than Chrome.

I confirm that the latest Firefox on Android is significantly slower than it used to be.

Does the -Dcanvas version perform faster on this version of Firefox?

@joshtynjala Yeah, I’ve experienced the same. It seems that with every update it got even worse. But this latest ‘update’ from 68 to 79 leaves me speechless. All of a sudden it’s also crashing on a regular basis. No exaggeration - for countless years I’m using Android devices and never had a single crash with any browser before. I bet you have a hard time getting your Feathers port working decently on FireFox too, do you? Is it using WebGL? In case it does, did you try enabling that option I’ve talked about?

@singmajesty Sorry, I can’t tell you. I’m using OpenFL’s Starling port so there’s no Canvas.

This appears to be a much broader issue for Firefox. Not looking good for the browser.