Loading scenes from Assetbundles not working (sometimes) in WebGL (Unity 5.4)

I’m getting an error for certain scenes in my project that prevents them from loading properly:

A script behaviour (script unknown or not yet loaded) has a different serialization layout when loading. (Read -100662820 bytes but expected 652 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

I’ve tried numerous things to address this from stripping all of the build flags and prefabs out of the scene to generating the scene without compression from both the legacy and new asset bundle system.

The only solution I’ve found thus far is to load the main manager class in the scene with every variable flagged as [NonSerialized]. While this will technically let me load the scene without the error but is problematic since there are numerous variables in the manager that contain things like prefabs and references to objects in the scene.

One important thing to mention is that this scene loaded without any issues from legacy asset bundles as of Unity 5.3.3 ( I haven’t tried it in 5.3.4 or 5.3.6).

If anyone needs code examples I can provide them but there’s a lot of text so I figure I’d just post my general issue for starters.

Are you trying to load an AssetBundle built in a different version of Unity?

I tried that initially but as of now everything is being built and ran in Unity 5.4.0p4. I tried using both the legacy bundle building as well as new scene bundles both with and without compression:

//our old code
stringerrorMsg=BuildPipeline.BuildStreamedSceneAssetBundle(levels,sFileName,BuildTarget.WebGL,BuildOptions.UncompressedAssetBundle);

//modified code from the assetbundlemanager example project
BuildPipeline.BuildAssetBundles(outputPath,BuildAssetBundleOptions.UncompressedAssetBundle,EditorUserBuildSettings.activeBuildTarget);

If you can file a bug report with a repro case, we can take a look. Though, are you sure that this issue is specific to WebGL? As the error message states, this happens when the serialization format does not match expectations, which can happen when you are using compiler defines in your variables setup.

I’ve only tried PC and WebGL platforms thus far with this project. It might occur with other platforms of course but I’m not sure. Also, I went ahead and was able to successfully build and run the project and bundles in 5.3.6p4 so if nothing else it’s definitely an issue that is limited to 5.4. The whole problem in all of this is that some very similar scenes to the one that isn’t loading DO load right before. If I can narrow it down any further I’ll be more than happy to try and put up a reproducable version of the bug.