0
Fixed

Bolt unable to update generted aot stubs

Tom 1 year ago updated by Lazlo Bonin (Lead Developer) 12 months ago 4

My class 'Storage' is added to Bolt as a custom build unit.

When I decided to change the name of a public method in it, Bolt started screaming that the method does not exist:

Assets/Ludiq/Ludiq.Core/Generated/AotStubs.cs(3147,42): error CS0117: 'Storage' does not contain a definition for 'SetBoosterVertLine'

Ok, understandable since I changed the interface. But why the hell updating the unit options and re-running the AOT pre build tool cannot fix this? I keep getting the same error and I can't even enter playmode. 

I suspect that clearing the library folder would fix it, but I hate doing it :/ This is obviously a bug that should be fixed asap!

Bolt Version:
1.4.4
Unity Version:
2019.1.6f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

For anyone facing the same problem, here's what fixed this deadlock for me:

1) Delete the type from build options, generate

2) Remove AotStubs.cs

3) Add the file again into build options, generate

4) Run AOT pre build

------- EDIT: -------

After I fixed this, I made a commit+push. Then my teammate pulled the changes and for him Bolt was a mess:

1) Storage type was not listed in the build unit options at all

2) Despite that, Storage type was available in the graphs, but presented only some methods.

So he had to go through the same process again...  

Pending Review

Hi Tom,

Sorry you're experiencing this issue.

Normally, Bolt should have been able to fix the error by just re-running AOT Pre-Build. It would then have regenerated a new version without the missing/renamed member; it's definitely a bug if that fails. I'll try to recreate the issue by changing a method signature and see why that might fail.

Regarding your version control issue, it depends on how you set up your Git ignore configuration. Usually, the type options should be shared, as long as you commit the ProjectSettings.asset file. You could also share the result of the unit options database by committing UnitOptions.db, although that is generally not recommended, because it adds bloat to your repository when you can just regenerate it after a commit. See this page for more information about version control: https://ludiq.io/bolt/manual/advanced/version-control

Working on Fix

Hi again,

Following up on this, I understand what's happening:

  1. The method is added to a graph
  2. Stubs are generated for it
  3. The method gets renamed; Unity fails to compile because of the stub script (important)
  4. Because compilation fails, the assemblies don't reload, and the graph keeps referencing the "old version" of the method from the library in memory
  5. When AOT stubs are regenerated, the "old version" of the method in memory is used as a reference for the stub to generate, so it regenerates a stub with the old name

The fix is to let Unity recompile between steps 3 and 4, then rerun the AOT pre-build wizard. As you noticed, the trick to make this work is to delete the AotStubs.cs file. I will add a menu option below "AOT Pre-Build..." to "Clear AOT Pre-Build" to make it convenient if this ever happens to someone else.

Hope that makes sense, sorry for the inconvenience!