Skip to content

Conversation

PaulDemeulenaere
Copy link
Contributor

@PaulDemeulenaere PaulDemeulenaere commented Aug 31, 2021


Purpose of this PR

Fix case https://fogbugz.unity3d.com/f/cases/1361601/

The regression has been introduced by #4971 & #5104 but it can't be tested prior this change, the last C++ producing the correct old behavior is 21.2a21.

0) What was happening before "Fix Sanitize" #4971 :
1st VFX import

  • Preprocess:
    • Sanitize applied, PrepareSubgraph called, CheckGraphBeforeImport processed, graph marked as sanitize
    • VFX Graph Compilation is executed 🟢
  • PostProcess: Nothing

The dependent shaderGraph is modified

  • Preprocess:
    • Sanitize is skipped (because already sanitize), CheckGraphBeforeImport processed, PrepareSubgraph called.
    • VFX Graph Compilation is executed 🟢
  • PostProcess : Nothing

1) After "Fix Sanitize" #4971
1st VFX import

  • Preprocess called:
    • Everything is skipped because not sanitized 🟠
  • PostProcess:
    • Sanitize applied, PrepareSubgraph called, CheckGraphBeforeImport processed, graph marked as sanitize
    • Reimport is triggered
  • Preprocess called:
    • PrepareSubgraph is called (which was problematic ⏳)
    • VFX Graph Compilation is executed 🟢
  • PostProcess: CheckGraphBeforeImport

The dependent shaderGraph is modified

  • Preprocess called:
    • Because the graph is already marked as sanitize, continue
    • PrepareSubgraph is called (still problematic)
    • VFX Graph Compilation is executed 🟢
  • PostProcess: CheckGraphBeforeImport

2) After "Fix Subgraph" #5104
Same than 1) but the PrepareSubgraph changes are now safely handled preventing any deleted references serialized in graph.

  • ...
  • Preprocess called:
    • VFX is backuped
    • PrepareSubgraph is called (which is no more an issue thanks to previous backup)
    • VFX Graph Compilation is executed 🟢
    • VFX is restored
      -...

The problem !
After first import the graph is marked as sanitized but the CheckGraphBeforeImport is occurring too late:
(...)
The dependent shaderGraph is modified

  • Preprocess called:
    • Because the graph is already marked as sanitize, continue
    • PrepareSubgraph is called
    • VFX Graph Compilation is executed => 🔴 It fails because this ResyncSlot is only called afterwards
  • PostProcess: CheckGraphBeforeImport

3) After this fix (and more precisely f62f1b6) adding CheckGraphBeforeImport process before compilation

  • ...
  • Preprocess called:
    • VFX is backuped
    • PrepareSubgraph is called
    • CheckGraphBeforeImport ◀️Fix 🔧
    • VFX Graph Compilation is executed 🟢
    • VFX is restored
  • PostProcess: CheckGraphBeforeImport (still needed because the previous one has been reverted)

N.B.: As PrepareSubgraph, the CheckGraphBeforeImport is safe during preprocess only because we are backuping/restoring the graph, otherwise, slot created during preprocess will be destroyed after the import.


Testing status

Tested locally with described repro step.

Tested manually at this revision (other integration branch) : 61ebca1
_fix_in_urp_integration

Added an editor regression test Modify_ShaderGraph_Property_Check_VFX_Compilation_Doesnt_Fail
It simulates the repro step modifying the shaderGraph content.

Before
image

After
image

Run all test locally
image

Yamato trunk 🟢
Yamato 2021.2 at cba0eba12ed723121f116ca85995475593fe3963 🟢


Comments to reviewers

We are planning a live code review on this change with @julienf-unity

N.B: We could also benefit from the rework of OnPostprocessAllAssets thanks to this PR but these changes hasn't landed in 21.2 (see this conversation)

+ Cleaner exception than a null ref exception
The regression has been probably introduced by #4971

What happens, 1st VFX import:
- Not Sanitized
- Skip first compilation
- PostProcess => Sanitize & CheckGraphBeforeImport
- Reimport

Later, the ShaderGraph changes
- Because the VFX is sanitized
- Doesn't skip the first compilation => Fail
- Post Process => CheckGraphBeforeImport is applied
- ... Later VFX import will be ok until the SG isn't modified.
@VitaVFX
Copy link

VitaVFX commented Sep 2, 2021

Thanks for the fix Paul! Quick summary - specifically Vector 3 issue seems to be fixed, but this bug is still lurking behind the corner (it happens with other properties under certain circumstances).

Here's the work in progress test doc, logged all the scenarios I managed to find about this main issue, also logged some not caused by the PR bugs, maybe something will draw your attention and could be fixed.

Equivalent change from e6d34d3
The following ContainsKey would have thrown an exception anyway
@VitaVFX
Copy link

VitaVFX commented Sep 9, 2021

Thanks for the fix!

Error is no longer persistent. Tried:

  • Various setups while testing SG integration to URP
  • Existing URP/HDRP projects
  • New URP/HDRP projects
  • Most of the properties created from inline nodes and through blackboard
  • Tried connecting all the vertex/fragment ports
  • Reimporting VFX/SG

Other issues raised in test doc are unrelated to PR.

@Unity-Technologies Unity-Technologies deleted a comment from github-actions bot Sep 10, 2021
@Unity-Technologies Unity-Technologies deleted a comment from github-actions bot Sep 10, 2021
@PaulDemeulenaere
Copy link
Contributor Author

I double checked the changelog.md, expected job are green 🟢 at this revision f6d7f03
Ready to be merged

@PaulDemeulenaere PaulDemeulenaere merged commit dca84e6 into master Sep 10, 2021
@PaulDemeulenaere PaulDemeulenaere deleted the vfx/fix/1361601-missing-check-graph-before-compile branch September 10, 2021 08:58
PaulDemeulenaere added a commit that referenced this pull request Sep 10, 2021
* Add Editor Test to cover issue 1361601

+ Cleaner exception than a null ref exception

* Actual fix from https://fogbugz.unity3d.com/f/cases/1361601/

The regression has been probably introduced by #4971

What happens, 1st VFX import:
- Not Sanitized
- Skip first compilation
- PostProcess => Sanitize & CheckGraphBeforeImport
- Reimport

Later, the ShaderGraph changes
- Because the VFX is sanitized
- Doesn't skip the first compilation => Fail
- Post Process => CheckGraphBeforeImport is applied
- ... Later VFX import will be ok until the SG isn't modified.

* *Update changelog.md

* More readable exception when failing to find expression

Equivalent change from e6d34d3
The following ContainsKey would have thrown an exception anyway

* Move changelog entry to 13.x.x
# Conflicts:
#	com.unity.visualeffectgraph/CHANGELOG.md
PaulDemeulenaere added a commit that referenced this pull request Sep 15, 2021
* Add Editor Test to cover issue 1361601

+ Cleaner exception than a null ref exception

* Actual fix from https://fogbugz.unity3d.com/f/cases/1361601/

The regression has been probably introduced by #4971

What happens, 1st VFX import:
- Not Sanitized
- Skip first compilation
- PostProcess => Sanitize & CheckGraphBeforeImport
- Reimport

Later, the ShaderGraph changes
- Because the VFX is sanitized
- Doesn't skip the first compilation => Fail
- Post Process => CheckGraphBeforeImport is applied
- ... Later VFX import will be ok until the SG isn't modified.

* *Update changelog.md

* More readable exception when failing to find expression

Equivalent change from e6d34d3
The following ContainsKey would have thrown an exception anyway

* Move changelog entry to 13.x.x
# Conflicts:
#	com.unity.visualeffectgraph/CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants