Crash when using addressables

I’m trying to convert our project to use addressables but I’ve started getting a crash (but only on Switch for some reason). See below for the log output.

Our loading flow involves loading a couple of mainly empty boot scenes followed by a loading scene which loads the front end scene using Addressables.LoadSceneAsync(). The crash happens just after the async loading of the front end scene has finished.

I have the following addressable groups set up: one with just the second boot scene, one with some fonts, one with just the loading scene, another with just the front end scene, another with one of the level scenes in it, and so on.

I have had this working fine, but at some point it started crashing. Any ideas what might be going on?

Debug Log excerpt:

Unable to find shaders used for the terrain engine. Please include Nature/Terrain/BillboardTree shader in Graphics settings.
0x3470faf2fc[SwitchPlayer.nss!GetStacktrace(int)+0x4c]
0x3470cd422c[SwitchPlayer.nss!DebugStringToFile(DebugStringToFileData const&)+0x16c]
0x3471da5628[SwitchPlayer.nss!TreeRenderer::CreateBillboardMaterial()+0x178]
0x3471da46c8[SwitchPlayer.nss!TreeRenderer::TreeRenderer(TreeDatabase&, Vector3f const&, bool)+0x2f8]
0x3471701b54[SwitchPlayer.nss!Terrain::CreateCameraData(int)+0x154]
0x3471db20ec[SwitchPlayer.nss!TerrainManager::CullAllTerrains(ScriptableCullingParameters const&, CullingParameters const&)+0x1fc]
0x34705b9978[SwitchPlayer.nss!CullScriptable(ScriptableRenderContext const&, ScriptableCullingParameters const&)+0x338]
0x3470e18670[SwitchPlayer.nss!ScriptableRenderContext_CUSTOM_Internal_Cull_Injected(ScriptableCullingParameters&, ScriptableRenderContextManaged const&, void*)+0x50]
0x346edadccc[SwitchPlayer.nss!ScriptableRenderContext_Internal_Cull_Injected_mBF4FAD3354E079A2BE20FE65B3D510EE33398B60+0x8c]
0x346edadc0c[SwitchPlayer.nss!ScriptableRenderContext_Internal_Cull_mFD76253744E69C86617B1CB320C206A0347269A2+0x6c]
0x346edb0fe8[SwitchPlayer.nss!ScriptableRenderContext_Cull_m193842B732EFDA3A6B462A06D4B656C0551F4889+0x278]
0x346e44d028[SwitchPlayer.nss!LightweightRenderPipeline_RenderSingleCamera_m4ABFD5490B30B98A135EC13633087EA76868DF2E+0xec8]
0x346e44aefc[SwitchPlayer.nss!LightweightRenderPipeline_Render_mAD4B807D90B1C896B4013C83BAA775DA911982DF+0x84c]
0x346f3cd7f8[SwitchPlayer.nss!RenderPipeline_InternalRender_m3601304F718BEEDCC63FAC61AF865392A1B97159+0x3e8]
0x346ed9fd80[SwitchPlayer.nss!RenderPipelineManager_DoRenderLoop_Internal_m3E55159BDC2CB6046ABDF67EA81D7876F159C826+0x400]
0x346ccea264[SwitchPlayer.nss!RuntimeInvoker_FalseVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017_RuntimeObject_RuntimeObject_IntPtr_t(void ()(), MethodInfo const, void*, void**)+0x24]
0x34701f0260[SwitchPlayer.nss!il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**)+0x70]
0x3470289b94[SwitchPlayer.nss!scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)+0x64]
0x347027274c[SwitchPlayer.nss!ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)+0x5c]
0x34705b2720[SwitchPlayer.nss!ScriptableRenderContext::ExtractAndExecuteRenderPipelineNoCleanup(dynamic_array<Camera*, 0ul> const&, void ()(SceneNode const, AABB const*, IndexList&, void*), void*)+0x160]
0x34705b2578[SwitchPlayer.nss!ScriptableRenderContext::ExtractAndExecuteRenderPipeline(dynamic_array<Camera*, 0ul> const&, void ()(SceneNode const, AABB const*, IndexList&, void*), void*)+0x18]
0x3470a8e1a8[SwitchPlayer.nss!RenderManager::RenderCamerasWithScriptableRenderLoop(int)+0x1f8]
0x3470a8e300[SwitchPlayer.nss!RenderManager::RenderCameras(int, void ()(), void ()())+0x30]
0x34705078c4[SwitchPlayer.nss!PlayerRender(bool)+0x134]
0x347050918c[SwitchPlayer.nss!InitPlayerLoopCallbacks()+0x142c]
0x347050c9ec[SwitchPlayer.nss!ExecutePlayerLoop(NativePlayerLoopSystem*)+0x5c]
0x347050ca44[SwitchPlayer.nss!ExecutePlayerLoop(NativePlayerLoopSystem*)+0xb4]
0x347050cc40[SwitchPlayer.nss!PlayerLoop()+0x110]
0x347026d950[SwitchPlayer.nss!nnMain+0xb60]
0x347c389f3c[nnSdk.nss!(unknown)+0x00]

(Filename: .\Modules/Terrain/Public/TreeRenderer.cpp Line: 292)

Stack trace:
0x000000347043DF14 _ZN8Material14CreateMaterialER6ShaderN6Object9HideFlagsEb+0x44
0x0000003471DA5554 _ZN12TreeRenderer23CreateBillboardMaterialEv+0xA4
0x0000003471DA46C8 _ZN12TreeRendererC1ER12TreeDatabaseRK8Vector3fb+0x2F8
0x0000003471701B54 _ZN7Terrain16CreateCameraDataEi+0x154
0x0000003471DB20EC _ZN14TerrainManager15CullAllTerrainsERK27ScriptableCullingParametersRK17CullingParameters+0x1FC
0x00000034705B9978 _Z14CullScriptableRK23ScriptableRenderContextRK27ScriptableCullingParameters+0x338
0x0000003470E18670 _Z53ScriptableRenderContext_CUSTOM_Internal_Cull_InjectedR27ScriptableCullingParametersRK30ScriptableRenderContextManagedPv+0x50
0x000000346EDADCCC ScriptableRenderContext_Internal_Cull_Injected_mBF4FAD3354E079A2BE20FE65B3D510EE33398B60+0x8C
0x000000346EDADC0C ScriptableRenderContext_Internal_Cull_mFD76253744E69C86617B1CB320C206A0347269A2+0x6C
0x000000346EDB0FE8 ScriptableRenderContext_Cull_m193842B732EFDA3A6B462A06D4B656C0551F4889+0x278
0x000000346E44D028 LightweightRenderPipeline_RenderSingleCamera_m4ABFD5490B30B98A135EC13633087EA76868DF2E+0xEC8
0x000000346E44AEFC LightweightRenderPipeline_Render_mAD4B807D90B1C896B4013C83BAA775DA911982DF+0x84C
0x000000346F3CD7F8 RenderPipeline_InternalRender_m3601304F718BEEDCC63FAC61AF865392A1B97159+0x3E8
0x000000346ED9FD80 RenderPipelineManager_DoRenderLoop_Internal_m3E55159BDC2CB6046ABDF67EA81D7876F159C826+0x400
0x000000346CCEA264 Z103RuntimeInvoker_FalseVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017_RuntimeObject_RuntimeObject_IntPtr_tPFvvEPK10MethodInfoPvPS4+0x24
0x00000034701F0260 _ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException+0x70
0x0000003470289B94 _Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb+0x64
0x000000347027274C _ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb+0x5C
0x00000034705B2720 ZN23ScriptableRenderContext40ExtractAndExecuteRenderPipelineNoCleanupERK13dynamic_arrayIP6CameraLm0EEPFvPK9SceneNodePK4AABBR9IndexListPvESE+0x160
0x00000034705B2578 ZN23ScriptableRenderContext31ExtractAndExecuteRenderPipelineERK13dynamic_arrayIP6CameraLm0EEPFvPK9SceneNodePK4AABBR9IndexListPvESE+0x18
0x0000003470A8E1A8 _ZN13RenderManager37RenderCamerasWithScriptableRenderLoopEi+0x1F8
0x0000003470A8E300 ZN13RenderManager13RenderCamerasEiPFvvES1+0x30
0x00000034705078C4 _Z12PlayerRenderb+0x134
0x000000347050918C _Z23InitPlayerLoopCallbacksv+0x142C (too far)
0x000000347050C9EC _Z17ExecutePlayerLoopP22NativePlayerLoopSystem+0x5C
0x000000347050CA44 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem+0xB4
0x000000347050CC40 _Z10PlayerLoopv+0x110
0x000000347026D950 nnMain+0xB60
0x000000347C389F3C (unknown)

Update: We’ve been able to prevent the crash by removing all the trees from the terrain and adding them back as game objects in the scene (we used an editor script to do this). Our trees were supposed to be using the Lightweight Render Pipeline/Lit shader so I guess the terrain system was substituting that with a built in shader which was not getting bundled.

Another interesting thing; I was originally putting all our scenes into addressables groups, not realizing that I needed to have the first launch scene in the editor build settings and not in a bundle. This was, somehow, still managing to work (mostly). I don’t know how the player decided which scene to load initially but it must have been picking the correct one by pure chance, until it suddenly started loading the wrong scene at launch. As soon as I took the boot scene out of the bundles and ticked it in the build settings I started getting the crash.