Skip to content
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

Crash in Windows 10 when drag and drop #559

Closed
GabrielMPhi opened this issue Apr 21, 2019 · 13 comments
Closed

Crash in Windows 10 when drag and drop #559

GabrielMPhi opened this issue Apr 21, 2019 · 13 comments
Labels
Milestone

Comments

@GabrielMPhi
Copy link

GabrielMPhi commented Apr 21, 2019

In Windows 10, latest version of Manuskript. I try dragging and dropping one or many folder (including scenes) in another folder and it crashs. I tried with one folder... and many folders and still it crash. In fact. When I drag and drop individual folder. The first transfer don't crash, but the second crash.

@worstje
Copy link
Contributor

worstje commented Apr 21, 2019

Before I dig into it and chase my own tail trying to figure out how to reproduce it, can you offer any more information?

Does it work with an empty folder?
Are there nested folders?
How many files are inside?
What types of files?

@GabrielMPhi
Copy link
Author

In "plan" mode, I have 4 folders (chapters) including 4 scenes. I created a new folder and wanted to move all four chapter in that new folder that I wanted to name Book 1, (inspired by the trilogy preset). I selected first the 4 folders at once and dragged them in the new folder (5th in the list) and it crashed. I tried the same but on folder (chapter) at a time... and after the 2nd, it crashed again.

@worstje
Copy link
Contributor

worstje commented Apr 21, 2019

I have noticed a crash once in the past when I was organising way back when, but I wasn't particularly interesting in figuring out the cause back then.

Anyway, I have tried moving around some folders in a test project just now and I can't seem to reproduce it though, even when following your instructions. (I assume you mean the outline screen when you talk about 'plan' mode).

Two more questions that come to mind:

  1. Are you saving to a single file? (See settings menu.)

  2. Do you have auto-saving turned on? If so, do you have revisions turned on? The latter slows down saving considerably and may make it more likely to trigger.

My guess is that you might be noticing some sort of race condition / inconsistency bug that is caused by the auto-save feature saving while the UI is trying to move files about when other parts of the code aren't expecting those bits to change. I've noticed things like those pop up once or twice in the past.

@GabrielMPhi
Copy link
Author

I'm sorry to be so unprecise. I try to be clearer in the future.

  1. Indeed. I'm saving in a single file
  2. I do have auto-saving turned on and also revisions (+ intelligent supression)

I disabled revisions and now the drag and drop is working just fine. Thanks a lot! I believe that I can reactivate revision now.

@worstje
Copy link
Contributor

worstje commented Apr 25, 2019

I am currently digging into the saving and outline drag-n-drop code, and I am not quite sure how those two interact as of yet. I did manage to cause a crash while messing around so far but it does not seem to involve saving functionality.

Can you run Manuskript from a command prompt and reproduce the bug (preferably with a sample project) to see exactly what kind of messages and traceback it produces, and then share it with us? I'll experiment a bit more to see what else I can do to make it crash, but I want to fully understand the problem before I start to try and patch the one thing I have observed myself.

worstje added a commit to worstje/manuskript that referenced this issue May 2, 2019
Describing all the rabbitholes that I and kakaroto have gone through
while debugging this one until dawn can frankly not do enough justice to
the crazy amount of rubberducking that went on while trying to fix this.

This bug would be triggered whenever you had a document open in the
editor and then moved an ancestor object downwards (visually) in the tree.
Or when you simply deleted the ancestor. Depending on the exact method
that caused the opened item to be removed from the internal model, the
exact nature of the bug would vary, which means this commit fixes a few
different bits of code that lead to what appears to be the same bug.

In order of appearance, the bugs that ruined our sleep were:

1) The editor widget was trying to handle the removed item at too late a
stage.

2) The editor widget tried to fix its view after a move by searching for
the new item with the same ID, but in the case of moving an object down
it came across its own old item, ruining the attempt.

3) The editor widget did not properly account for the hierarchical
nature of the model.

Upon fixing these the next day, it was revealed that:

4) The outlineItem.updateWordCount(emit=False) flag is broken. This
function would call setData() in several spots which would still cause
emits to bubble through the system despite emit=False, and we simply got
lucky that it stopped enough of them until now.

This last one was caused by a small mistake in the fixes for the first
three bugs, but it has led to a couple of extra changes to make any
future bug hunts slightly less arduous and frustrating:

a) When calling item.removeChild(c), it now resets the associated parent
and model to mirror item.insertChild(c). This has also led to an extra
check in model.parent() to check for its validity.

b) The outlineItem.updateWordCount(emit=) flag has been removed entirely
and it now emits away with reckless abandon. I have been unable to
reproduce the crashes the code warned about, so I consider this a code
quality fix to prevent mysterious future issues where things sometimes
do not properly update right.

Worthy of note is that the original code clearly showed the intention to
close tabs for items that were removed. Reworking the editor to support
closing a tab is unfortunately way out of scope, so this intention was
left in and the new fix was structured to make it trivial to implement
such a change when the time comes. An existing FIXME regarding unrelated
buggy editor behaviour was left in, too.

Many thanks to Kakaroto for burning the midnight oil with me to get to
the bottom of this. (I learned a lot that night!)

Issues olivierkes#479 and olivierkes#559 are fixed by this commit. And maybe some others,
too.
worstje added a commit to worstje/manuskript that referenced this issue May 11, 2019
Describing all the rabbitholes that I and kakaroto have gone through
while debugging this one until dawn can frankly not do enough justice to
the crazy amount of rubberducking that went on while trying to fix this.

This bug would be triggered whenever you had a document open in the
editor and then moved an ancestor object downwards (visually) in the tree.
Or when you simply deleted the ancestor. Depending on the exact method
that caused the opened item to be removed from the internal model, the
exact nature of the bug would vary, which means this commit fixes a few
different bits of code that lead to what appears to be the same bug.

In order of appearance, the bugs that ruined our sleep were:

1) The editor widget was trying to handle the removed item at too late a
stage.

2) The editor widget tried to fix its view after a move by searching for
the new item with the same ID, but in the case of moving an object down
it came across its own old item, ruining the attempt.

3) The editor widget did not properly account for the hierarchical
nature of the model.

Upon fixing these the next day, it was revealed that:

4) The outlineItem.updateWordCount(emit=False) flag is broken. This
function would call setData() in several spots which would still cause
emits to bubble through the system despite emit=False, and we simply got
lucky that it stopped enough of them until now.

This last one was caused by a small mistake in the fixes for the first
three bugs, but it has led to a couple of extra changes to make any
future bug hunts slightly less arduous and frustrating:

a) When calling item.removeChild(c), it now resets the associated parent
and model to mirror item.insertChild(c). This has also led to an extra
check in model.parent() to check for its validity.

b) The outlineItem.updateWordCount(emit=) flag has been removed entirely
and it now emits away with reckless abandon. I have been unable to
reproduce the crashes the code warned about, so I consider this a code
quality fix to prevent mysterious future issues where things sometimes
do not properly update right.

Worthy of note is that the original code clearly showed the intention to
close tabs for items that were removed. Reworking the editor to support
closing a tab is unfortunately way out of scope, so this intention was
left in and the new fix was structured to make it trivial to implement
such a change when the time comes. An existing FIXME regarding unrelated
buggy editor behaviour was left in, too.

Many thanks to Kakaroto for burning the midnight oil with me to get to
the bottom of this. (I learned a lot that night!)

Issues olivierkes#479 and olivierkes#559 are fixed by this commit. And maybe some others,
too.

Changes according to code review

Removed some pointless checks. Also cleaned up some variable names,
comments and a docstring.

It also adds a bugfix for non-updating tab titles in the editor.
worstje added a commit to worstje/manuskript that referenced this issue May 12, 2019
Describing all the rabbitholes that I and kakaroto have gone through
while debugging this one until dawn can frankly not do enough justice to
the crazy amount of rubberducking that went on while trying to fix this.

This bug would be triggered whenever you had a document open in the
editor and then moved an ancestor object downwards (visually) in the tree.
Or when you simply deleted the ancestor. Depending on the exact method
that caused the opened item to be removed from the internal model, the
exact nature of the bug would vary, which means this commit fixes a few
different bits of code that lead to what appears to be the same bug.

In order of appearance, the bugs that ruined our sleep were:

1) The editor widget was trying to handle the removed item at too late a
stage.

2) The editor widget tried to fix its view after a move by searching for
the new item with the same ID, but in the case of moving an object down
it came across its own old item, ruining the attempt.

3) The editor widget did not properly account for the hierarchical
nature of the model.

Upon fixing these the next day, it was revealed that:

4) The outlineItem.updateWordCount(emit=False) flag is broken. This
function would call setData() in several spots which would still cause
emits to bubble through the system despite emit=False, and we simply got
lucky that it stopped enough of them until now.

This last one was caused by a small mistake in the fixes for the first
three bugs, but it has led to a couple of extra changes to make any
future bug hunts slightly less arduous and frustrating:

a) When calling item.removeChild(c), it now resets the associated parent
and model to mirror item.insertChild(c). This has also led to an extra
check in model.parent() to check for its validity.

b) The outlineItem.updateWordCount(emit=) flag has been removed entirely
and it now emits away with reckless abandon. I have been unable to
reproduce the crashes the code warned about, so I consider this a code
quality fix to prevent mysterious future issues where things sometimes
do not properly update right.

Worthy of note is that the original code clearly showed the intention to
close tabs for items that were removed. Reworking the editor to support
closing a tab is unfortunately way out of scope, so this intention was
left in and the new fix was structured to make it trivial to implement
such a change when the time comes. An existing FIXME regarding unrelated
buggy editor behaviour was left in, too.

Many thanks to Kakaroto for burning the midnight oil with me to get to
the bottom of this. (I learned a lot that night!)

Issues olivierkes#479 and olivierkes#559 are fixed by this commit. And maybe some others,
too.

Changes according to code review

It also adds a bugfix for non-updating tab titles in the editor.
Fix for issue olivierkes#516 + extra safety checks.

A modified safety check has been added back in for the signals where
these could protect against a buggy situation.

Technically speaking, olivierkes#516 is out of scope... but it is a trivial fix,
so why not? :-)
@gedakc
Copy link
Collaborator

gedakc commented May 16, 2019

Can someone provide an exact list of steps that reproduce this crash?

Following is the testing I performed.

Test 1 - Drag and Drop Chapter into other Chapter

  1. Create a new Manuskript project using the Novel template
  2. Select the Editor pane
  3. Select Chapter 2
  4. Drag and drop into Chapter 3
  5. Select Chapter 8 plus Chapter 9 using shift+click
  6. Drag and drop into Chapter 6

OBSERVATIONS:

  • Manuskript 0.9.0 on Kubuntu 16.04: no crash observed.
  • Manuskript 0.9.0 on Windows 10: no crash observed.

Test 2 - Drag and Drop Chapter beside other Chapters

  1. Create a new Manuskript project using the Novel template
  2. Select the Editor pane
  3. Select Chapter 2
  4. Drag and drop between Chapter 3 and Chapter 4
  5. Select Chapter 8 plus Chapter 9 using shift+click
  6. Drag and drop between Chapter 5 and Chapter 6

OBSERVATIONS:

  • Manuskript 0.9.0 on Kubuntu 16.04: no crash observed.
  • Manuskript 0.9.0 on Windows 10: no crash observed.

SUMMARY

So far I am unable to reproduce the crash.

Note that I do have Edit -> Settings -> Revisions enabled.

EDIT: I have also tried changing step 2 to be "Select Outline pane" and I am still unable to reproduce the crash.

@kakaroto
Copy link
Contributor

It only crashes IF a text being moved (a child of the chapter) is open in the editor pane AND you do the move in the Outline pane, AND you move the chapter down not up in the order (For example, moving chapter 2 between chapters 3 and 4 would crash, it wouldn't crash if you move chapter 3 between chapters 1 and 2)

@gedakc
Copy link
Collaborator

gedakc commented May 16, 2019

Thanks @kakaroto for the tip.

EDIT: My bad - was testing with PR 571 applied. Unfortunately I am still unable to reproduce the crash (I tested on Kubuntu 16.04).

Following are the steps I used to test.

Test 3 - Drag and Drop Chapter with Open Text beside other Chapters

  1. Create a new Manuskript project using the Novel template
  2. Select the Editor pane
  3. Expand Chapter 2 to show the scene texts
  4. Select Scene 3
  5. Select the Outline pane
  6. Select Chapter 2
  7. Drag and drop between Chapter 3 and Chapter 4

No crash observed.

With Manuskript 0.9.0, a crash occurs at completion of step 7.

Please let me know what I need to change to recreate the crash.

@kakaroto
Copy link
Contributor

Ha! I just tested and confirmed the issue, came to say I don't know why you don't get the crash, and saw the edit!
Looks like you confirmed the crash and the fix as well :)

@gedakc
Copy link
Collaborator

gedakc commented May 16, 2019

'Just finished testing with Windows 10.

Both Windows 10 and Kubuntu 16.04 crash using the above Test 3 steps with Manuskript 0.9.0.

When PR 571 is applied, both Windows 10 and Kubuntu 16.04 do not crash.

@worstje
Copy link
Contributor

worstje commented May 16, 2019

@gedakc After having all those emails while out for dinner giving me a serious pit-of-my-stomach feeling about screwing up the fix, that is literally the best comment you could have posted tonight. 😄

@gedakc
Copy link
Collaborator

gedakc commented May 16, 2019

@worstje sorry about that. My bad not using the master branch to confirm the original crash report.

worstje added a commit to worstje/manuskript that referenced this issue May 18, 2019
Describing all the rabbitholes that I and kakaroto have gone through
while debugging this one until dawn can frankly not do enough justice to
the crazy amount of rubberducking that went on while trying to fix this.

This bug would be triggered whenever you had a document open in the
editor and then moved an ancestor object downwards (visually) in the tree.
Or when you simply deleted the ancestor. Depending on the exact method
that caused the opened item to be removed from the internal model, the
exact nature of the bug would vary, which means this commit fixes a few
different bits of code that lead to what appears to be the same bug.

In order of appearance, the bugs that ruined our sleep were:

1) The editor widget was trying to handle the removed item at too late a
stage.

2) The editor widget tried to fix its view after a move by searching for
the new item with the same ID, but in the case of moving an object down
it came across its own old item, ruining the attempt.

3) The editor widget did not properly account for the hierarchical
nature of the model.

Upon fixing these the next day, it was revealed that:

4) The outlineItem.updateWordCount(emit=False) flag is broken. This
function would call setData() in several spots which would still cause
emits to bubble through the system despite emit=False, and we simply got
lucky that it stopped enough of them until now.

This last one was caused by a small mistake in the fixes for the first
three bugs, but it has led to a couple of extra changes to make any
future bug hunts slightly less arduous and frustrating:

a) When calling item.removeChild(c), it now resets the associated parent
and model to mirror item.insertChild(c). This has also led to an extra
check in model.parent() to check for its validity.

b) The outlineItem.updateWordCount(emit=) flag has been removed entirely
and it now emits away with reckless abandon. I have been unable to
reproduce the crashes the code warned about, so I consider this a code
quality fix to prevent mysterious future issues where things sometimes
do not properly update right.

Worthy of note is that the original code clearly showed the intention to
close tabs for items that were removed. Reworking the editor to support
closing a tab is unfortunately way out of scope, so this intention was
left in and the new fix was structured to make it trivial to implement
such a change when the time comes. An existing FIXME regarding unrelated
buggy editor behaviour was left in, too.

Many thanks to Kakaroto for burning the midnight oil with me to get to
the bottom of this. (I learned a lot that night!)

Issues olivierkes#479, olivierkes#516 and olivierkes#559 are fixed by this commit. And maybe some others,
too.
@gedakc gedakc added this to the 0.10.0 milestone May 18, 2019
@gedakc gedakc added the bug label May 18, 2019
gedakc pushed a commit that referenced this issue May 19, 2019
Describing all the rabbitholes that I and kakaroto have gone through
while debugging this one until dawn can frankly not do enough justice to
the crazy amount of rubberducking that went on while trying to fix this.

This bug would be triggered whenever you had a document open in the
editor and then moved an ancestor object downwards (visually) in the tree.
Or when you simply deleted the ancestor. Depending on the exact method
that caused the opened item to be removed from the internal model, the
exact nature of the bug would vary, which means this commit fixes a few
different bits of code that lead to what appears to be the same bug.

In order of appearance, the bugs that ruined our sleep were:

1) The editor widget was trying to handle the removed item at too late a
stage.

2) The editor widget tried to fix its view after a move by searching for
the new item with the same ID, but in the case of moving an object down
it came across its own old item, ruining the attempt.

3) The editor widget did not properly account for the hierarchical
nature of the model.

Upon fixing these the next day, it was revealed that:

4) The outlineItem.updateWordCount(emit=False) flag is broken. This
function would call setData() in several spots which would still cause
emits to bubble through the system despite emit=False, and we simply got
lucky that it stopped enough of them until now.

This last one was caused by a small mistake in the fixes for the first
three bugs, but it has led to a couple of extra changes to make any
future bug hunts slightly less arduous and frustrating:

a) When calling item.removeChild(c), it now resets the associated parent
and model to mirror item.insertChild(c). This has also led to an extra
check in model.parent() to check for its validity.

b) The outlineItem.updateWordCount(emit=) flag has been removed entirely
and it now emits away with reckless abandon. I have been unable to
reproduce the crashes the code warned about, so I consider this a code
quality fix to prevent mysterious future issues where things sometimes
do not properly update right.

Worthy of note is that the original code clearly showed the intention to
close tabs for items that were removed. Reworking the editor to support
closing a tab is unfortunately way out of scope, so this intention was
left in and the new fix was structured to make it trivial to implement
such a change when the time comes. An existing FIXME regarding unrelated
buggy editor behaviour was left in, too.

Many thanks to Kakaroto for burning the midnight oil with me to get to
the bottom of this. (I learned a lot that night!)

Issues #479, #516 and #559 are fixed by this commit. And maybe some others,
too.
@gedakc
Copy link
Collaborator

gedakc commented May 19, 2019

This issue has been resolved in the develop branch and will be included in the next release of Manuskript.

@gedakc gedakc closed this as completed May 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants