inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
4.06k stars 486 forks source link

Build crashes on build machine (-nographics option) #544

Open dh-milcho opened 5 years ago

dh-milcho commented 5 years ago

We've been getting crashes on our build machine recently when building our game:

build    19-Aug-2019 12:41:04    Updating ProjectSettings/ProjectSettings.asset - GUID: 00000000000000004000000000000000...
build    19-Aug-2019 12:41:04     done. [Time: 16.341331 ms] 
build    19-Aug-2019 12:41:04    Unloading 555 Unused Serialized files (Serialized files now loaded: 0)
build    19-Aug-2019 12:41:04    System memory in use before: 220.9 MB.
build    19-Aug-2019 12:41:04    System memory in use after: 221.4 MB.
build    19-Aug-2019 12:41:04    
build    19-Aug-2019 12:41:04    Unloading 368 unused Assets to reduce memory usage. Loaded Objects now: 5843.
build    19-Aug-2019 12:41:04    Total: 37.013162 ms (FindLiveObjects: 0.627431 ms CreateObjectMapping: 0.354894 ms MarkObjects: 35.904490 ms  DeleteObjects: 0.125023 ms)
build    19-Aug-2019 12:41:04    
build    19-Aug-2019 12:41:04    Refreshing native plugins compatible for Editor in 48.02 ms, found 16 plugins.
build    19-Aug-2019 12:41:04    Preloading 0 native plugins for Editor in 0.00 ms.
build    19-Aug-2019 12:41:04    Ink Library was rebuilt.
build    19-Aug-2019 12:41:04    Crash!!!

This seems to happen when we have the InkCompiler included in the project. When we remove the InkCompiler the problem disappears. We're using Unity 2019.1.8f1 with Ink 0.9.1

Let me know if I can share more logs or the crash dump to help resolve this. We don't want to remove the InkCopiler from the project just yet since it's useful for auto compiling. This is the stack trace:

build    19-Aug-2019 12:41:04    ========== OUTPUTTING STACK TRACE ==================
build    19-Aug-2019 12:41:04    
build    19-Aug-2019 12:41:06    0x00007FF725E1A757 (Unity) SortByExecutionOrder
build    19-Aug-2019 12:41:06    0x00007FF725E02497 (Unity) std::_Insertion_sort_unchecked<SavedObject * __ptr64,bool (__cdecl*)(SavedObject const & __ptr64,SavedObject const & __ptr64)>
build    19-Aug-2019 12:41:06    0x00007FF725E02F80 (Unity) std::stable_sort<SavedObject * __ptr64,bool (__cdecl*)(SavedObject const & __ptr64,SavedObject const & __ptr64)>
build    19-Aug-2019 12:41:06    0x00007FF725E0B5A6 (Unity) MonoManager::EndReloadAssembly
build    19-Aug-2019 12:41:06    0x00007FF725E16882 (Unity) MonoManager::ReloadAssembly
build    19-Aug-2019 12:41:06    0x00007FF72410A2A6 (Unity) ReloadAllUsedAssemblies
build    19-Aug-2019 12:41:06    0x00007FF724104516 (Unity) HandleCompileStatus
build    19-Aug-2019 12:41:06    0x00007FF7240FFF5A (Unity) CompileScriptsWait
build    19-Aug-2019 12:41:06    0x00007FF7240FF7BA (Unity) CompileDirtyScriptsForEditorSyncInternal
build    19-Aug-2019 12:41:06    0x00007FF7240FF63B (Unity) CompileDirtyScriptsForEditorSync
build    19-Aug-2019 12:41:06    0x00007FF7240FFBF1 (Unity) CompileScriptsForEditorSync
build    19-Aug-2019 12:41:06    0x00007FF724107F41 (Unity) LoadMonoAssembliesAndRecompileIfNecessary
build    19-Aug-2019 12:41:06    0x00007FF7246619A8 (Unity) Application::InitializeProject
build    19-Aug-2019 12:41:06    0x00007FF7249358FA (Unity) WinMain
build    19-Aug-2019 12:41:06    0x00007FF727278B5E (Unity) __scrt_common_main_seh
build    19-Aug-2019 12:41:06    0x00007FFDCC854034 (KERNEL32) BaseThreadInitThunk
build    19-Aug-2019 12:41:06    0x00007FFDCCC83691 (ntdll) RtlUserThreadStart
build    19-Aug-2019 12:41:06    
build    19-Aug-2019 12:41:06    ========== END OF STACKTRACE ===========
build    19-Aug-2019 12:41:06    

One thing that might be responsible, which I noticed just now when making a build locally, is a popup that prompts you to build outdated Ink files when making the build. Maybe this can have something to do with it (since we're using the -nographics -batchmode Unity switch on the build machine)

tomkail commented 5 years ago

Hi! This would be more appropriate at https://github.com/inkle/ink-unity-integration, but yeah; it sounds like the auto-prompt. We don't have build machines so this has never come up, but I'd be very interested in a solution, if you find one! I don't think Unity has a way of detecting it a build is done the "normal" way?

dh-milcho commented 5 years ago

I believe you can check for "nographics" and "batchmode" by doing something like this:

string commandLineOptions = System.Environment.CommandLine;

    if (commandLineOptions.Contains("-batchmode") )
    {
        Debug.Log("Batch mode!");
    }
    else if (commandLineOptions.Contains("-nographics") )
    {
       Debug.Log("No Graphcis Mode");
    }

But yeah not sure what else we can do except removing the compiler from the project (or force the build machine to ignore it somehow). Should I post this in https://github.com/inkle/ink-unity-integration as well?

tomkail commented 5 years ago

Oh great! I'm not set up to test this, but a fix that sounds good to me is to early out of InkPreBuildValidationCheck.PreprocessValidationStep if in batch/nographics mode (I'm not sure which is best). Ideally it'd log a warning if it would have popped up that dialogue box so you can find out if something went less than perfectly. If it works then feel free to submit a pull request or just send me a code snippet and I'll sort it.

Thanks!

We might as well just keep the issue here now we're close to solving it (we manage both projects at inkle anyway).

tomkail commented 5 years ago

Hum, although your log makes it seem that it's the "Ink Library was rebuilt." that leads to the crash? Does the issue resolve just by removing the InkCompiler.cs, or do you remove the entire ink integration system?