Currently WorkSpaces.scene_viewlayer_relations link to ViewLayer via WorkSpaceDataRelation.value.
This works when the workspace and scene are stored in the same file, but crashes when a workspace & window is used to display a library linked scene.
In general this is something we don't support - referencing library pointers only works via ID's (I should have picked this up in initial review).
Checked on supporting this, but libraries don't have a datamap. This could be supported but is going outside the realm of what's reasonable regarding library loading. (snipped of kind of change that would be needed to support this - P622).
- Suggest to use a string for the view layer as we do with bones.
- An alternative solution would be to always ignore the workspace view layer with linked scenes, but this seems weak.