Page MenuHome

Moving collections between scenes crashes Blender
Closed, ResolvedPublicBUG


System Information
Operating system: Windows 10 x64
Graphics card: Gtx2070

Blender Version
Broken: blender-2.91.0-29780b8101eb-windows64
Behavior changed in rB89491d67d96f: Fix T81545: Moving nested collections changes view layer flags

Short description of error
Moving collections between internal scenes hard crashes Blender.

Exact steps for others to reproduce the error
Open the attached scene and drag and drop the the Drag_Me_2_Scene.001 from Scene to Scene.001 or take a look at the attached image

Event Timeline

Robert Guetzkow (rjg) changed the task status from Needs Triage to Confirmed.EditedNov 5 2020, 10:21 PM
Robert Guetzkow (rjg) triaged this task as High priority.
Robert Guetzkow (rjg) changed the subtype of this task from "Report" to "Bug".

I can confirm this crash in current master and 2.91. layer_collection is NULL in layer_collection_flags_restore .

_BLI_assert_abort() Lines 51	C
layer_collection_flags_restore(ListBase * flags, const Collection * collection) Lines 1818	C
BKE_collection_move(Main * bmain, Collection * to_parent, Collection * from_parent, Collection * relative, bool relative_after, Collection * collection) Lines 1878	C
collection_drop_invoke(bContext * C, wmOperator * UNUSED_op, const wmEvent * event) Lines 1289	C
wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Lines 1288	C
wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const bool poll_only, wmEvent * event) Lines 1534	C
wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Lines 2781	C
wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Lines 2864	C
wm_event_do_handlers(bContext * C) Lines 3360	C
WM_main(bContext * C) Lines 481	C
main(int argc, const unsigned char * * UNUSED_argv_c) Lines 526	C

This seems to work fine in Blender 2.83 in a cursory test.

After looking at the code here it seems that it's fundamentally broken in cases where multiple scenes are involved. It basically assumes that the collection is being moved to the same view layer it's already in, because it searches in the original view layer for the moved collection.

A simple solution would be to just remove the assert and skip the collection when no view layer is found, but I feel like there should be a proper way around this. One way to solve this would be to pass the "to view layer" which would then be searched for the new LayerCollection for the collection.

However, I don't think this would deal with the case where the same collection is in two scenes at the same time. It almost looks like we would need a separate list of LayerCollectionFlags for each scene, and that putting them all in the same list isn't correct.

As a side note linking via Ctrl dragging does not crash Blender.

Robert Guetzkow (rjg) added a comment.EditedNov 6 2020, 9:23 AM

For reference, the commit that introduced the changed/broken behavior was rB89491d67d96f0bf104e65d88fbc39fee9ebaced6

@Bastien Montagne (mont29) I was away for a few days but I'm planning to work on this in the next day or two.