iOS build crashes at Xth async sceneload. "Could not open file... for read"

Hello all.

In our game we have a main menu scene, and a game scene. We switch between them to keep memory usage low. Up until now, everything has worked just fine, but after upgrading to Unity 5 (this project started a long time ago), Unity now refuses to read any of the .assets files in the package (including scene files) after X scene switches. Sometimes we can play 3 games before it happens, sometimes its 7 games. Its never less than 3. We are loading the Game Scene asynchronously, and loading the Main Menu scene synchronously.

This always happens at the Game Scene load, not the Main Menu scene load.

The app then crashes hard. We have code expecting to find other code in the Game Scene, which then causes a shitstorm of nullrefs, because the Game Scene file could not be read.

We are using Unity 5.1.2.p3 - we also tried 5.1.2f1. Same issue. I’m posting the xCode log below.

I’m having a hard time reproducing this bug in a clean project that just switches scenes, and I’m worried that the bug might only show in a project with lots of stuff in there. I probably can’t submit our project to Unity - theres some legal stuff there, that we’re not quite sure of.

EDIT: I should say, that this does not happen in editor or in our Android build.

xCode log below:

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/projecttitan.app/Data/level1 for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/level1 for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Failed to load 'level1' because its serialized file version is higher than what this version of Unity supports.
(Filename: /Users/builduser/buildslave/unity/build/Runtime/Misc/LoadSceneOperation.cpp Line: 83)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/level1 for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/level1 for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/sharedassets2.assets for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/sharedassets2.assets for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/level1 for read
(Filename: /Users/builduser/buildslave/unity/build/Runtime/File/OpenFileCache.cpp Line: 54)

Could not open file /private/var/mobile/Containers/Bundle/Application/FB11D8B2-09FB-4B6B-AF5D-4A9FD2E991C0/
projecttitan.app/Data/level1 for read

Slight update, if we revert to Unity 5.0.4, the crash will occur at the very first async scene load. In case this helps anyone.

Sounds like we might be running out of file handles.
But we would need your project to debug that.

Alright. I have not been able to produce a clean project that reproduces the bug, but I will ask the powers that be about submitting our entire project. As I understand it, project files are hidden from the public, yes?

A bug has been submitted with the project attached - case no: 721316.

Hi, any news on this? With the current latest full release (Unity 5.1.3.f1) - we are getting this crash after a single scene reload, it seems.

I know there are lots of bugs to look at, we’re just curious if this has been given a look at all yet :slight_smile:

A Unity dev has responded to the bug report, and this bug is fixed internally and should ship with 5.2. Solved

We are experiencing this same issue in 5.2.1p3 - What version is this expected to be fixed in?

We are experiencing this same issue too with a message: “10-31 20:44:51.450: E/Unity(23485): Could not open file mem:/BuildPlayer-RaceCarScene.sharedAssets/BuildPlayer-RaceCarScene.sharedAssets for read”
in Unity 5.2.2f1

Sounds like different issue. Please submit a bugreport.
Thanks!