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

JSON reader should be key-order independent #90

Open
gmlewis opened this issue May 12, 2019 · 2 comments
Open

JSON reader should be key-order independent #90

gmlewis opened this issue May 12, 2019 · 2 comments
Assignees

Comments

@gmlewis
Copy link

gmlewis commented May 12, 2019

If the animations key within an artboard appears before the nodes key in the same object, the flare_flutter plugin will crash due to the _collections container not being populated yet.

The JSON reader should work regardless of key order within any JSON object.

For example, this JSON .flr file will crash the reader because the keys are in sorted order (which is the default for writers like https://golang.org/pkg/encoding/json/#Marshal):

{"artboards":[{"animations":[{"animationEnd":0.6,"animationStart":0,"duration":0.6,"fps":25,"isLooping":true,"keyed":[{"component":0,"opacity":[[{"interpolatorType":1,"time":0.24,"value":0},{"interpolatorType":1,"time":0.36,"value":1},{"interpolatorType":1,"time":0.48,"value":1},{"interpolatorType":1,"time":0.6,"value":0}]]},{"component":3,"opacity":[[{"interpolatorType":1,"time":0.12,"value":0},{"interpolatorType":1,"time":0.24,"value":1},{"interpolatorType":1,"time":0.36,"value":1},{"interpolatorType":1,"time":0.48,"value":0}]]},{"component":6,"opacity":[[{"interpolatorType":1,"time":0,"value":0},{"interpolatorType":1,"time":0.12,"value":1},{"interpolatorType":1,"time":0.24,"value":1},{"interpolatorType":1,"time":0.36,"value":0}]]}],"name":"idle","type":"animation"}],"clipContents":true,"color":[0,0,0,1],"height":200,"name":"Artboard","nodes":[{"blendMode":3,"clips":[],"drawOrder":1,"isCollapsed":false,"isVisible":true,"name":"Shape Layer 3","opacity":1,"rotation":0,"scale":[1,1],"translation":[128,100],"type":"shape"},{"color":[0.7921569,0.8156863,0.8352941,1],"fillRule":1,"name":"Fill 1","opacity":1,"parent":0,"type":"colorFill"},{"clips":[],"height":14.963,"isCollapsed":false,"name":"Ellipse Path 1","opacity":1,"parent":0,"rotation":0,"scale":[1,1],"translation":[0,0],"type":"ellipse","width":14.963},{"blendMode":3,"clips":[],"drawOrder":2,"isCollapsed":false,"isVisible":true,"name":"Shape Layer 1","opacity":1,"rotation":0,"scale":[1,1],"translation":[99.875,100],"type":"shape"},{"color":[0.7921569,0.8156863,0.8352941,1],"fillRule":1,"name":"Fill 1","opacity":1,"parent":3,"type":"colorFill"},{"clips":[],"height":14.963,"isCollapsed":false,"name":"Ellipse Path 1","opacity":1,"parent":3,"rotation":0,"scale":[1,1],"translation":[0,0],"type":"ellipse","width":14.963},{"blendMode":3,"clips":[],"drawOrder":3,"isCollapsed":false,"isVisible":true,"name":"Shape Layer 2","opacity":1,"rotation":0,"scale":[1,1],"translation":[71.75,100],"type":"shape"},{"color":[0.7921569,0.8156863,0.8352941,1],"fillRule":1,"name":"Fill 1","opacity":1,"parent":6,"type":"colorFill"},{"clips":[],"height":14.963,"isCollapsed":false,"name":"Ellipse Path 1","opacity":1,"parent":6,"rotation":0,"scale":[1,1],"translation":[0,0],"type":"ellipse","width":14.963}],"origin":[0,0],"translation":[0,0],"type":"artboard","width":200}],"version":21}
@luigi-rosso
Copy link
Contributor

Thanks @gmlewis, we are aware of this one. It's a byproduct of the JSON loader being based off of our binary loader, which does have guaranteed order. We have a few ideas in mind for how to fix this.

@gmlewis
Copy link
Author

gmlewis commented May 15, 2019

For others running into this issue, I have written a temporary workaround to fix the problem:
https://github.com/gmlewis/lottie2flare/tree/master/cmd/flare-bug-workaround

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

3 participants