FlowCanvas Forums › Support › AOT in a On-Demand Resources game using AssetBundle
Hello Gavalakis and all Flow Canvas team,
Thanks in advice for your support and congrats for the fabulous assets.
I’m currently working on a mobile iOS and Android game that requires on-demand resources using Asset Bundles, mini-games and animations are stored in a server and download in real-time when the user request them.
The entire app is based on that and as Asset Bundles can’t contains new C# components because of the AOT compile. So I choose to create them using Flow Canvas.
As we all know Flow Canvas allow us to add Preferred Types inside the build-in editor and export them to in order to be accessible on iOS and other AOT restricted platforms.
That said, this process of adding classes and structs time by time can be done in a normal application that know, at a given time, what kind of types the device needs to user.
In our case this process does not fit exactly our needs. We would like to be able to export asset bundle and have them readable on mobile devices, and we cannot update the app when new on-demand resources are used.
So this works OK until a new Type is added, after that a “Attempting to call method for which no ahead of time (AOT) code was generated.” shows up and the object flow canvas script stops. This can be solved by updating the app locally and on the stores, but it’s something that goes against our Cloud-based concept.
I’m currently working on Unity 5.6.0f3 on a Mac, I’m using Flow Canvas 1.3.6 and testing on an iPhone 6, iOS 10.3.1 on xCode 8.3.3.
My questions are:
1. Would you recommend to add the entire unity namespace inside the preferred type script to make them all readable on iOS? The app i’m woking on is pretty big in size, and it doesn’t metter if 10-15 mb are added. Am I going to have memory issues with this approach? Is this going to solve my issue, of course if only Unity-namespace methods, classes and structs are used? Are your AOTClasses capable of doing this? or is there another way?
2. Is the method above going to add dozen of unused types inside the Flow Canvas script windows? I suppose so. Do you think using 2 different preset for production (exporting on mobile to generate AOT classes and xml) and development (use types on canvases) might solve this issue?
3. Is there a way to test Flow canvas in editor in a AOT compile replication? I’m not aware if there is any way to do so in Unity Mac osx. Unfortunately building everytime to iOS takes me 30 minutes.
4. I’m currently experiencing an issue where I added RaycastHit and all similar struct inside the Preferred Type editor as visible in this IMAGE . The error is :
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ExecutionEngineException: Attempting to call method ‘FlowCanvas.ValueOutput`1[[UnityEngine.RaycastHit&, UnityEngine, Version=0.0.0.0, Culture=, PublicKeyToken=null]]::.ctor’ for which no ahead of time (AOT) code was generated.
And after this a Null reference error, probably because of the result of the RaycastHit is null.
On this GITHUB link you can check out the entire xCode log, along with the AOTClasses file generated and the link.xml. I will try to reproduce the error locally and send you a repository to test on your own.
Thanks agin, if you have any advices on how to debug these issue, they will be much appreciated.
Robert.
Hello,
Thank you for your positive feedback and the detailed post!
I think that the best approach around this, would be to provide an extra c# AOTClasses file along with each bundle that would contain all generated AOT classes for the graphs in that bundle. Does including an extra c# file with the bundle is possible for you?
With that said, right now creating multiple AOTClasses.cs files and having them all together is not really easy since one overwrites the other and they both use the same class name, but I could of course make a few changes, so that this could be done a bit easier, by each generated file, having it’s own class name so that there be no conflicts between one another.
With that done, you would then need to generate a different AOTClasses file for each different graph and bundle it in the Asset Bundle. Would that work?
To answer your questions:
1. Adding the whole UnityEngine namespace would create some problems both in the editor as well as in the generation due to the complexity of all the types that are included in the UnityEngine namespace (which I would gladly look after fixing and doing so right now), but even so, it would take a hell lot of a time to compile due to the amount of classes and methods generated. So, I wouldn’t really recommend adding every thing :/
2. As you foresee, the types added in the list, would interfere with the editor usage, by having all of them show (as well as make the editor slower to respond in certain cases. One solution around this, like you said, would be to create and use different type list presets in the Preferred Types editor, one being for “working” in the editor, and another for the actual AOTClasses file “generation”. That is definitely a valid workflow.
3. There is no way I know of and this is really something I wish it could be done myself and would have been a true time save if possible. I have searched everywhere for this but to no avail :-/
4. Regarding the problem and just to confirm, is this error log WITH the generated AOTClasses file that is on the GITHUB link? I suppose it is, but it doesn’t seem right for the error to throw since RaycastHit does exist in the generated files. Hmm. I will take a look at this tomorrow and try to reproduce this, just in case I’ve missed something and let you know as soon as possible. If I can get a hand on the repository just for the shake of testing the same project, that would of course also be great.
Please, also let me know regarding my first suggestion above, about using a separate AOTClasses generated file for each graph, bundled with the graph in the Asset Bundle, and whether or not that would be a valid solution/workflow for you.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh