Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with '-useLegacyAOT no' #75

Open
johnstejskal opened this issue Jun 28, 2014 · 29 comments
Open

Doesn't work with '-useLegacyAOT no' #75

johnstejskal opened this issue Jun 28, 2014 · 29 comments

Comments

@johnstejskal
Copy link

I can only get this Library to work with standard compiling, when using the new quick compile with '-useLegacyAOT no' gestures no longer work.

This is fine, but with large projects which can take up to 1 hour to compile, it becomes a problem. Is there anyway to have this library work with the quick compile?

@fljot
Copy link
Owner

fljot commented Jun 29, 2014

That's for iOS packaging, right? Then I can't test anymore – don't have certificates and everything..

You can try debugging yourself starting with
https://github.com/fljot/Gestouch/blob/master/src/org/gestouch/core/Gestouch.as#L30
then
https://github.com/fljot/Gestouch/blob/master/src/org/gestouch/input/NativeInputAdapter.as#L70
then
https://github.com/fljot/Gestouch/blob/master/src/org/gestouch/input/NativeInputAdapter.as#L144
and so on...

It should be very easy once you find where the chain is broken.
Maybe might be related to mushroom operator issue introduced in ASC 2.0 compiler?

@remunizz
Copy link

remunizz commented Aug 1, 2014

It looks like GestureState const items are interpreted as the same object, in _initClass function "POSSIBLE.setValidNextStates(RECOGNIZED, BEGAN, FAILED);" RECOGNIZED, BEGAN, FAILED its the same static object.

My solution:
in org.gestouch.core.GestureState i changed:
"public static const POSSIBLE:GestureState = new GestureState("POSSIBLE");
public static const RECOGNIZED:GestureState = new GestureState("RECOGNIZED", true);
public static const BEGAN:GestureState = new GestureState("BEGAN");
public static const CHANGED:GestureState = new GestureState("CHANGED");
public static const ENDED:GestureState = new GestureState("ENDED", true);
public static const CANCELLED:GestureState = new GestureState("CANCELLED", true);
public static const FAILED:GestureState = new GestureState("FAILED", true);"

to:
"private static var cls:Class = GestureState;
public static const POSSIBLE:GestureState = new cls("POSSIBLE") as GestureState;
public static const RECOGNIZED:GestureState = new cls("RECOGNIZED", true) as GestureState;
public static const BEGAN:GestureState = new cls("BEGAN") as GestureState;
public static const CHANGED:GestureState = new cls("CHANGED") as GestureState;
public static const ENDED:GestureState = new cls("ENDED", true) as GestureState;
public static const CANCELLED:GestureState = new cls("CANCELLED", true) as GestureState;
public static const FAILED:GestureState = new cls("FAILED", true) as GestureState;"

look at: http://helpx.adobe.com/flash-builder/actionscript-compiler-backward-compatibility.html
to understand the changes of the new compiler.

@fljot
Copy link
Owner

fljot commented Aug 3, 2014

@remunizz
Kudos for the finding!
So you've tested, that change totally did the trick?

@johnstejskal
Copy link
Author

@fljot An update to the latest AIR SDK (4.6) also fixed this issue,
The issue was initially experienced in AIR 4.0

@fljot
Copy link
Owner

fljot commented Aug 5, 2014

@johnstejskal latest AIR SDK is 14. Was that typo?

@remunizz @johnstejskal so I'm confused, should I make any changes or it works fine with the latest SDK and compiler?

@johnstejskal
Copy link
Author

My apologies, yes AIR 14 is working with 'useLegacyAOT no'

@remunizz
Copy link

remunizz commented Aug 6, 2014

@fljot @johnstejskal Yes, My fix is for earlier versions of AIR 14,
i will update my IDE, up AIR SDK to 14 and post the results, thanks for the update.

@jonathonpitman
Copy link

This seems to be broken again in AIR 16. I need to update an app for 64 Bit Support and this fix isn't working :(

Does anyone know of a fix for AIR 16 ?

Any help is appreciated.

@fljot
Copy link
Owner

fljot commented Jan 10, 2015

@jonathonpitman as I said before, I can't test that. But there was another problem related to GestureState static initialization recently #71 which is solvable, but still.. maybe I should get rid of static initialization thing and do that states configuration differently.

@fljot
Copy link
Owner

fljot commented Jan 10, 2015

@johnstejskal I summon you

@jonathonpitman
Copy link

Tried the for loop fix as well.. still doesn't work with -useLegacyAOT no :(

@fljot
Copy link
Owner

fljot commented Jan 10, 2015

@jonathonpitman ok as a first quickfix option I recommend you to try to replace const with var and create those in _initClass() method. If won't work – we need to move those static constants into different class.

@jonathonpitman
Copy link

in which file do I need to do this ?

@fljot
Copy link
Owner

fljot commented Jan 10, 2015

GestureState we are talking about

@jonathonpitman
Copy link

You mean change for example

public static const POSSIBLE:GestureState = new cls("POSSIBLE") as GestureState;

to

public static var POSSIBLE:GestureState = new cls("POSSIBLE") as GestureState;

What do I put in the _initClass ?

@fljot
Copy link
Owner

fljot commented Jan 12, 2015

@jonathonpitman yes, const to var, but then you put new ... into _initClass()

@jonathonpitman
Copy link

LIke

public static var POSSIBLE:GestureState;

then

POSSIBLE = new cls("POSSIBLE") as GestureState;

Like that ?

@jonathonpitman
Copy link

No errors .. this is what I have changed... still doesnt work though.

package org.gestouch.core
{
import flash.utils.Dictionary;
import flash.errors.IllegalOperationError;

/**
 * @author Pavel fljot
 */
final public class GestureState
{

    private static var cls:Class = GestureState;
    public static var POSSIBLE:GestureState;
    public static var RECOGNIZED:GestureState;
    public static var BEGAN:GestureState;
    public static var CHANGED:GestureState;
    public static var ENDED:GestureState;
    public static var CANCELLED:GestureState;
    public static var FAILED:GestureState;

    private static var allStatesInitialized:Boolean;


    private var name:String;
    private var eventType:String;
    private var validTransitionStateMap:Dictionary = new Dictionary();

    {
        _initClass();
    }


    public function GestureState(name:String, isEndState:Boolean = false)
    {
        if (allStatesInitialized)
        {
            throw new IllegalOperationError("You cannot create gesture states." +
            "Use predefined constats like GestureState.RECOGNIZED");
        }

        this.name = "GestureState." + name;
        this.eventType = "gesture" + name.charAt(0).toUpperCase() + name.substr(1).toLowerCase();
        this._isEndState = isEndState;
    }


    private static function _initClass():void
    {

    POSSIBLE = new cls("POSSIBLE") as GestureState;
    RECOGNIZED = new cls("RECOGNIZED", true) as GestureState;
    BEGAN = new cls("BEGAN") as GestureState;
    CHANGED = new cls("CHANGED") as GestureState;
    ENDED = new cls("ENDED", true) as GestureState;
    CANCELLED = new cls("CANCELLED", true) as GestureState;
    FAILED = new cls("FAILED", true) as GestureState;



        POSSIBLE.setValidNextStates(RECOGNIZED, BEGAN, FAILED);
        RECOGNIZED.setValidNextStates(POSSIBLE);
        BEGAN.setValidNextStates(CHANGED, ENDED, CANCELLED);
        CHANGED.setValidNextStates(CHANGED, ENDED, CANCELLED);
        ENDED.setValidNextStates(POSSIBLE);
        FAILED.setValidNextStates(POSSIBLE);
        CANCELLED.setValidNextStates(POSSIBLE);

        allStatesInitialized = true;
    }


    public function toString():String
    {
        return name;
    }


    private function setValidNextStates(...states):void
    {
        for each (var state:GestureState in states)
        {
            validTransitionStateMap[state] = true;
        }
    }


    gestouch_internal function toEventType():String
    {
        return eventType;
    }


    gestouch_internal function canTransitionTo(state:GestureState):Boolean
    {
        return (state in validTransitionStateMap);
    }


    private var _isEndState:Boolean = false;
    gestouch_internal function get isEndState():Boolean
    {
        return _isEndState;
    }
}

}

@fljot
Copy link
Owner

fljot commented Jan 12, 2015

What is "doesn't work" exactly? Is it the same issues as originally that constants are somehow all equal? Or what? Does _initClass() method even executed?

Try inlining static initializator (_initClass()) (see example below).

If you're short in time and need a really quickfix, try to move all constants into another class, let's say GestureStates (note the trailing s) or GestureStateEnum:

final public class GestureStates
{
    public static const POSSIBLE:GestureState = new GestureState("POSSIBLE");
    ...
    //do the static initialization method
    //or even try inline it like this
    {
        POSSIBLE.setValidNextStates(RECOGNIZED, BEGAN, FAILED);
    }
}

@fljot
Copy link
Owner

fljot commented Jan 12, 2015

Make some effort, it's just a few calls! Cmon people, I don't have any profiles to test myself.

@jonathonpitman
Copy link

What's not working for me is that it becomes unresponsive. No touch detected. There are no errors though.

Even when debugging from iOS to the remote debugger there is no errors.

@jonathonpitman
Copy link

I am really confused here.. sorry ;(

@jonathonpitman
Copy link

Something crashes the whole app .. nothing responds once Gestouch is initialized. ... Strange that no errors are thrown though.

@fljot
Copy link
Owner

fljot commented Jan 13, 2015

Well you have to add some logs to understand where it don't work, right?

@jonathonpitman
Copy link

I have put in trace statements. I can see that the _init function is called. So it is getting that far.

@fljot
Copy link
Owner

fljot commented Jan 13, 2015

So, are the gesture states (constants) initialized properly?

@jonathonpitman
Copy link

Weird... Everything is working with the new public release of AIR 16

@fljot
Copy link
Owner

fljot commented Jan 14, 2015

And this is why I'm leaving Flash platform...

@jonathonpitman
Copy link

to make matters worse... Now everything is working great in my app .. I submitted it and Apple rejected it instantly.

Invalid Binary Error

Minimum OS Version Mismatch - The minimum OS version (LC_VERSION_MIN_IPHONEOS) in the binary ('6.0') for architecture ('armv7') differs from the MinimumOSVersion ('7.0') in the Info.plist.

Ughhhh! .. It's really tooo bad. I love making apps in AIR .. it's so easy to make cross platform apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants