View Issue Details

IDProjectCategoryView StatusLast Update
0001647SketcherBugpublic2015-10-06 12:46
Reportermghansen256 Assigned Toabdullah  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
PlatformLinux 64 bitOSKubuntuOS Version14.04
Product Version0.14 
Target VersionFixed in Version0.16 
Summary0001647: Sketcher blocks or hangs when changing a constraint
DescriptionI am making the sketch attached below. When I change the topmost length constraint from 2mm to 4mm, the sketcher hangs for longer than 3 minutes (killed freecad then) and the UI is not redrawn.

When I do not change the constraint, but keep adding about 10 more lines, the sketcher reacts very slowly, with the UI locking up for about 10 seconds for every operation.
TagsNo tags attached.
FreeCAD Information

Relationships

related to 0001397 closed FreeCAD Random hangs at 100% CPU while editing sketches 

Activities

mghansen256

2014-07-29 20:16

reporter  

Bosch.fcstd (5,360 bytes)

Sterna

2014-07-29 22:30

reporter   ~0004875

I can confirm this bug and give further information (I'm running 0.14 on OSX 10.9.4)
This usually happens with large and advanced sketches when adding or changing a constraint so that it is overconstrained. For me, Freecad eventually (after several minutes) does come around and reports that most constraints are conflicting.
Perhaps add an option to kill solver if it has been working for a certain amount of time. Often when I encounter this is when I try to fully constrain the sketch and guess which constraints are needed. I only need an indication that this was wrong, not that Freecad says everything is wrong.

wmayer

2014-07-30 10:55

administrator   ~0004876

Apparently, that's a problem starting with Ubuntu 14.04 (not sure about 13.10) that the PPA package is built with debug symbols and thus the execution speed is by factors lower than it could be.

With Ubuntu 12.04 we don't have this issue.

Anyway, the solution is to explicitly switch on optimization in the build script.

@Sterna: I don't know why on MacOSX you have this problem too but it can also be due to debug symbols. Is on your OS a tool available similar to "nm" on UNIX? If yes, you can check one of the library files (.dylib or .so?) and look if there are any symbols defined. If yes you should get a long list of cryptic names, if not the output is very short or even empty.

Sterna

2014-07-30 12:28

reporter   ~0004883

Yes, I do have nm on my system. Where/how do I find these libs? I'm using the prebuilts Freecad, because I cannot build it myself for several reasons. This is the version of Freecad I'm using:
OS: Mac OS X
Word size: 64-bit
Version: 0.14.3703 (Git)
Branch: releases/FreeCAD-0-14
Hash: c6edd47334a3e6f209e493773093db2b9b4f0e40
Python version: 2.7.5
Qt version: 4.8.6
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0

wmayer

2014-07-30 12:49

administrator   ~0004884

OK, then e.g. pick the file PartDesign.so (.dylib) -- it is part of the FreeCAD installation -- and use the tool nm.

Sterna

2014-07-30 12:57

reporter   ~0004885

Yes, I do have lots of symbols defined for _PartDesign.so. Perhaps the problem is that it uses debug symbols for me as well.

wmayer

2014-07-30 13:20

administrator   ~0004886

@Peter, can you have a look if the MacOSX binaries include debug symbols?

mghansen256

2014-07-30 13:50

reporter   ~0004887

@wmayer: I tested the attached sketch in FreeCAD 0.14 on WinXP32Bit, and get the same hang when I change the constraint from 2mm to 4mm.

OS: Windows XP
Word size: 32-bit
Version: 0.14.3700 (Git)
Branch: releases/FreeCAD-0-14
Hash: 32f5aae0a64333ec8d5d160dbc46e690510c8fe1
Python version: 2.6.2
Qt version: 4.5.2
Coin version: 3.1.0
SoQt version: 1.4.1

About the debug symbols on Ubuntu, as far as I know debug symbols and optimization are not related, you can make an -O3 build with debug symbols. They just help the debugger to resolve to report function names and line numbers.

Also, when the UI starts acting slowly on the sketch, the solver still reports that it was done within 10ms or so.

wmayer

2014-07-30 15:19

administrator   ~0004888

> About the debug symbols on Ubuntu, as far as I know debug symbols and optimization are not related, you can make an -O3 build with debug symbols. They just help the debugger to resolve to report function names and line numbers.

Really? But the binaries become much bigger, right? Does this mean when you build with debug option on and use the tool strip afterwards it's like you didn't build with debug option?

ickby

2014-07-30 15:33

developer   ~0004889

But many librarys define extra checks when debug is enabled and so does eigen3. This makes this very slow, even if compiled with optimisations.

peterl94

2014-07-30 15:35

developer   ~0004890

I always do the os x builds with CMAKE_BUILD_TYPE=Release, but nm still lists lots of symbols. Looking at the makefiles, I can see that the release flags are being used:
CXX_FLAGS = -Wno-deprecated -Wno-write-strings -D_OCC64 -O3 -DNDEBUG -arch x86_64 -fPIC

wmayer

2014-07-30 16:40

administrator   ~0004893

Peter, can you confirm the slowness with your current build? As a test you can try the horse example from the one guy in the forum.
In case it's slow for you too then run the tool strip to remove any symbols from at least the Sketcher modules and try again.

We should also check if we build with full debug information (i.e. -g) fro the PPA. Here we should add a printf() statement into Application::init() inside an #ifdef _DEBUG/#endif and then start FreeCAD in the terminal to look for this message.

wmayer

2014-07-30 18:46

administrator   ~0004895

> I tested the attached sketch in FreeCAD 0.14 on WinXP32Bit,
OK, I have tested the file on Windows 7 and I can confirm this behaviour. So apparently this problem is not related to the optimization issue with PPA.

peterl94

2014-07-30 19:00

developer   ~0004896

Yeah, I guess so. I can move everything fine in horsie.fcstd, but it hangs for a while when trying to change the dimension in the attached file.

wmayer

2014-07-30 19:02

administrator   ~0004897

Inside System::solve_DL we have a classical endless loop. There is no stop criterion implemented to leave after a certain number of iterations. When doing this inside the debugger manually you'll get the message:
"Cannot set the datum because the sketch contains conflicting constraints."

ickby

2014-07-31 05:26

developer   ~0004900

That is not true, we have a max iteration criteria dependend on system size in line 1148 of GCS.cpp:

else if (iter >= maxIterNumber)
    stop = 4;

with

#define MaxIterations 100

and

int maxIterNumber = MaxIterations * xsize;

bejant

2014-07-31 06:33

reporter   ~0004901

Last edited: 2014-07-31 06:38

View 3 revisions

I tried an this case I don't think the topmost 2mm constraint can be changed at all. I can't even make it smaller; after a few minutes FreeCAD reports the error message "Cannot set the datum because the sketch contains conflicting constraints" that wmayer referenced in his most recent post. FreeCAD also reports that it is because of the conflicting constraints 18,38,39,44,45,46,47,48,53,55.

 It seems to me that Equality Constraints 18 and 46 are redundant in that they both make Edges 4 and 10 equal. Edge 10 is the horizontal line that the topmost constraint (Constraint 55) constrains to 2mm. Edge 4 is the short vertical edge on the far left, halfway down between the two 2mm horizontal distance constraints.

OS: Ubuntu 12.04.4 LTS
Word size: 32-bit
Version: 0.15.3796 (Git)
Branch: master
Hash: c10ddae02f676fce3bb3c9667f460f3f90909769
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0

wmayer

2014-07-31 08:31

administrator   ~0004904

Last edited: 2014-07-31 08:32

View 2 revisions

But in this example xsize is 150 so that the limit is 15000. And since the function is called three times or more we have 45000 cycles.

When deleting the above conflicting constraints and changing one of the remaining distances the solver needs around 6 iterations and is called around ten times but only two times he does something. So, we have 12 iterations vs. 45000 iterations.

logari81

2014-08-27 19:31

developer   ~0005014

The first thing that I would try in examples like this, is if any of the other solvers available in gcs perform better than the dogleg solver (solve_DL).

We had put the dogleg as the first solver but actually we had never compared the available solvers systematically.

In the state of FreeCAD that I remember the dogleg solver is called first. If it fails, a second solver is called and then a third one. But if the first solver takes forever the second and third solvers never get a chance to solve the problem.

Apart from that, choosing more reasonable max iterations limits is also important.

abdullah

2015-09-07 12:57

manager   ~0006340

In the meantime Sketcher performance has improved quite a lot.

I have been using the Sketcher for a while without "sketch size multiplier".

This option was introduced with the "Advanced Solver Control" and is only available in the development branch. What this does is just do not weight maxiterations with xsize, just do maxiterations.

I have not run into a situation where the solver needed more than 100 iterations to solve a sketch.

If with this configuration I open this sketch now, it will tell me that the new datum is invalid in around 30 seconds.

I think that it is correct to say that the constraint of 4 mm is conflicting in this sketch, so for this case, the result, I think, it is the expected result.

Issue History

Date Modified Username Field Change
2014-07-29 20:16 mghansen256 New Issue
2014-07-29 20:16 mghansen256 File Added: Bosch.fcstd
2014-07-29 22:30 Sterna Note Added: 0004875
2014-07-30 10:55 wmayer Note Added: 0004876
2014-07-30 12:28 Sterna Note Added: 0004883
2014-07-30 12:49 wmayer Note Added: 0004884
2014-07-30 12:57 Sterna Note Added: 0004885
2014-07-30 13:20 wmayer Note Added: 0004886
2014-07-30 13:50 mghansen256 Note Added: 0004887
2014-07-30 15:19 wmayer Note Added: 0004888
2014-07-30 15:33 ickby Note Added: 0004889
2014-07-30 15:35 peterl94 Note Added: 0004890
2014-07-30 16:40 wmayer Note Added: 0004893
2014-07-30 18:46 wmayer Note Added: 0004895
2014-07-30 19:00 peterl94 Note Added: 0004896
2014-07-30 19:02 wmayer Note Added: 0004897
2014-07-31 05:26 ickby Note Added: 0004900
2014-07-31 06:33 bejant Note Added: 0004901
2014-07-31 06:35 bejant Note Edited: 0004901 View Revisions
2014-07-31 06:38 bejant Note Edited: 0004901 View Revisions
2014-07-31 08:31 wmayer Note Added: 0004904
2014-07-31 08:32 wmayer Note Edited: 0004904 View Revisions
2014-08-27 19:31 logari81 Note Added: 0005014
2015-01-02 12:46 wmayer Relationship added related to 0001397
2015-09-07 12:29 abdullah Assigned To => abdullah
2015-09-07 12:29 abdullah Status new => assigned
2015-09-07 12:57 abdullah Note Added: 0006340
2015-10-06 12:46 abdullah Status assigned => closed
2015-10-06 12:46 abdullah Resolution open => fixed
2015-10-06 12:46 abdullah Fixed in Version => 0.16