Draft Workbench Bug (which leads to a crash)

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Draft Workbench Bug (which leads to a crash)

Post by MRx »

OS: macOS 10.15
Word size of FreeCAD: 64-bit
Version: 0.20.26556 (Git)
Build type: Release
Branch: adaptive_dicretize_bugfix
Hash: 4357816c94ff4938b778eb9f8aba8fe0e1c917dc
Python version: 3.9.0
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.0
Locale: English/Germany (en_DE)


09:58:25 Traceback (most recent call last):
File "/Users/markus/devel/freecad/build/Mod/Draft/draftutils/todo.py", line 167, in doTasks
Gui.doCommand(string)
File "<string>", line 1, in <module>
NameError: name 'nan' is not defined

09:58:25 ToDo.doTasks, Unexpected error:
<class 'NameError'>
in ['pl = FreeCAD.Placement()', 'pl.Rotation.Q = (-0.7071067811865475, -1.48949964615761e-14, 1.4916645362981988e-14, 0.7071067811865476)', 'pl.Base = FreeCAD.Vector(264.4811932979572, -8.499999999999945, -1.6146078033251756)', 'rec = Draft.make_rectangle(length=nan, height=nan, placement=pl, face=True, support=None)', 'Draft.autogroup(rec)', 'FreeCAD.ActiveDocument.recompute()']
first of all I'm selecting the two lines in the draft workbench
afterwards I click "current working plane" (the two lines should align the working plane to it)

Afterwards I set the snapping rules:
Snap Lock
Snap Endpoint

Finally I try to connect the two lines with a 2 point rectangle, in the property window I'm getting NAN mm if I try to snap to the edges.
Also the screen flickers here, maybe those values are passed forward to coin3d which cannot handle it.

Now in my big object it's guaranteed that freecad will crash if I proceed with clicking, in that cutout example (where I copied the two particular edges) it doesn't crash but prints errors.
Attachments
draftcrash.FCStd
(3.21 KiB) Downloaded 17 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Workbench Bug (which leads to a crash)

Post by Roy_043 »

I have tested your scenario, and I can't confirm: no crash and no errors. I have created 4 Draft_Rectangles using a different endpoint as the first point each time. Draft has an "internal precision level" setting and a "Tolerance" setting. It may be worth looking at those: Draft_Preferences#General_settings. But I have my doubts if they are the cause here.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of FreeCAD: 64-bit
Version: 0.20.26761 (Git)
Build type: Release
Python version: 3.8.12
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: Dutch/Netherlands (nl_NL)
Attachments
draftcrash-no-crash-roy.FCStd
(9.23 KiB) Downloaded 8 times
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: Draft Workbench Bug (which leads to a crash)

Post by MRx »

Did you see the "NaN" and flickering? Yes the crashing only happens on my larger object (where I took those two lines from)

Tolerances in FreeCAD seem to be messed up the real settings aren't applied everywhere it seems, and I'm having big trouble to fix those problems.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Workbench Bug (which leads to a crash)

Post by Roy_043 »

MRx wrote: Tue Jan 18, 2022 9:04 am Did you see the "NaN" and flickering?
No, and No.
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: Draft Workbench Bug (which leads to a crash)

Post by MRx »

tKxwyQ.png
tKxwyQ.png (20 KiB) Viewed 1481 times
the flickering did not happen this time either, however it did lead to a crash on the original object.

The NaN problem is still reproducible (and possibly causes other issues in the background when passing the values forward).
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Workbench Bug (which leads to a crash)

Post by Roy_043 »

You did not mention that you also have Draft_Snap_WorkingPlane activated.
But repeating my test with that snap additionally activated still shows no issue.

Try upgrading FreeCAD. If that does not help it may be OS related?
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: Draft Workbench Bug (which leads to a crash)

Post by Syres »

MRx wrote: Tue Jan 18, 2022 2:06 am Now in my big object it's guaranteed that freecad will crash if I proceed with clicking, in that cutout example (where I copied the two particular edges) it doesn't crash but prints errors.
Here's the output (no errors or crash) compiled from today's master using two different OCC's on Linux, Python Console output so you can see I followed the steps:

Code: Select all

FreeCAD.openDocument('/home/john/Downloads/draftcrash.FCStd')
# App.setActiveDocument("draftcrash")
# App.ActiveDocument=App.getDocument("draftcrash")
# Gui.ActiveDocument=Gui.getDocument("draftcrash")
Gui.runCommand('Std_OrthographicCamera',1)
App.activeDocument().recompute(None,True,True)
### Begin command Std_Workbench
Gui.activateWorkbench("DraftWorkbench")
### End command Std_Workbench
# Gui.Selection.addSelection('draftcrash','m','Edge2',263.174,-8.5,-2.86252)
# Gui.Selection.addSelection('draftcrash','m','Edge1',264.479,-8.5,-2.51827)
FreeCADGui.Snapper.setGrid()
# Gui.Selection.clearSelection()
Gui.runCommand('Draft_Rectangle',0)
# Gui.Selection.addSelection('draftcrash','m','Edge2',263.174,-8.5,-3.7583)
import Draft
pl = FreeCAD.Placement()
pl.Rotation.Q = (-0.7071067811865475, -1.48949964615761e-14, 1.4916645362981988e-14, 0.7071067811865476)
pl.Base = FreeCAD.Vector(263.174194, -8.5, -1.653000000000008)
rec = Draft.make_rectangle(length=1.3051960419998068, height=2.146999999999992, placement=pl, face=True, support=None)
# Gui.Selection.addSelection('draftcrash','Rectangle')
Draft.autogroup(rec)
FreeCAD.ActiveDocument.recompute()
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('draftcrash','Rectangle','Face1',264.474,-8.5,-1.67202)
Report View output:

Code: Select all

12:16:57  Draft workbench activated.
12:17:05  ----------------
12:17:05  GuiCommand: Rectangle
12:17:05  Pick first point
12:17:08  Pick opposite point

OS: Linux Mint 19.3 (X-Cinnamon/cinnamon)
Word size of FreeCAD: 64-bit
Version: 0.20.27089 (Git)
Build type: Release
Branch: master
Hash: ead1bce8e994358388fd6dd993f0c9b756ec0eac
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)

OS: Linux Mint 19.3 (X-Cinnamon/cinnamon)
Word size of FreeCAD: 64-bit
Version: 0.20.27089 (Git)
Build type: Release
Branch: master
Hash: ead1bce8e994358388fd6dd993f0c9b756ec0eac
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.6.0.beta
Locale: English/UnitedKingdom (en_GB)
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: Draft Workbench Bug (which leads to a crash)

Post by MRx »

There's a bug with Coin3D in the Draft workbench which can crash FreeCAD. I'm always starting FreeCAD on the same console, I have around 20 crashes in the backlog of the terminal.

Something might fail with listeners and duplicate registration (not particular from one part, but from another part of the code) might fail.
This is something to watch out for.
I had the same issue with some Path modifications which I have added in my local FreeCAD version.

The draft workbench has several smaller issues, eg. Draft to Sketch re-position the sketch to the origin of the object, the user has to fix the position himself at the moment.
drmacro
Veteran
Posts: 8867
Joined: Sun Mar 02, 2014 4:35 pm

Re: Draft Workbench Bug (which leads to a crash)

Post by drmacro »

I never need to fix positions...

I also can't confirm the crash, tried several scenarios.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: Draft Workbench Bug (which leads to a crash)

Post by MRx »

Yes, the file is fine, first you need to enter an unstable state in the draft workbench - then you would see it. I still need to figure out how to enter the unstable state. It happens regularly here so I should be able to figure that out within the next days.
Post Reply