Skip to content

Dont remove suboutputs objects if it cannot be deserialized #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix various bugs in Position (Cone) block [Case 1111053](https://issuetracker.unity3d.com/product/unity/issues/guid/1111053/)
- Fix space issues with blocks and operators taking a camera as input
- Generated shaderName are now consistent with displayed system names
- Don't lose SRP output specific data when SRP package is not present

## [8.0.1] - 2020-02-25

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ private void SanitizeSubOutputs()
return;
}

// TODO Uncommenting this code will removed SRP data that are unknown, this is probably not what we want
//int nbRemoved = 0;
//if ((nbRemoved = m_SubOutputs.RemoveAll(s => s == null)) > 0)
// Debug.LogWarningFormat("Remove {0} SRP Sub Outputs that could not be deserialized from {1} of type {2}", nbRemoved, name, GetType());
// Reference equals because we only need to remove actual null sub-output, not the ones that cannot be deserialized
// Because we want to keep reference to unknown SRP outputs. No log because this is internal clean up
m_SubOutputs.RemoveAll(s => object.ReferenceEquals(s, null));

var subOutputsTypes = new HashSet<Type>(); // TODO For some reason constructor that takes a capacity does not exist
for (int i = 0; i < m_SubOutputs.Count; ++i)
Expand All @@ -140,11 +139,7 @@ public override void CollectDependencies(HashSet<ScriptableObject> objs, bool ow
{
base.CollectDependencies(objs, ownedOnly);
foreach (var data in m_SubOutputs)
if (data != null)
{
objs.Add(data);
data.CollectDependencies(objs, ownedOnly);
}
objs.Add(data);
}

public override VFXSetting GetSetting(string name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static UnityEditor.VFX.VFXAbstractRenderedOutput;

namespace UnityEditor.VFX
Expand All @@ -24,6 +25,9 @@ public void Init(VFXAbstractRenderedOutput owner)
public virtual bool supportsExposure { get { return false; } }
public virtual bool supportsMotionVector { get { return false; } }

// Sealed override as SRP suboutputs cannot have dependencies
public sealed override void CollectDependencies(HashSet<ScriptableObject> objs, bool ownedOnly = true) {}

public virtual string GetBlendModeStr()
{
switch (owner.blendMode)
Expand Down
6 changes: 5 additions & 1 deletion com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ public object Backup()
dependencies.Add(this);
CollectDependencies(dependencies);

var result = VFXMemorySerializer.StoreObjectsToByteArray(dependencies.Cast<ScriptableObject>().ToArray(), CompressionLevel.Fastest);
// This is a guard where dependencies that couldnt be deserialized (because script is missing for instance) are removed from the list
// because else StoreObjectsToByteArray is crashing
// TODO Fix that
var safeDependencies = dependencies.Where(o => o != null);
var result = VFXMemorySerializer.StoreObjectsToByteArray(safeDependencies.ToArray(), CompressionLevel.Fastest);

Profiler.EndSample();

Expand Down