Go to file
robnee b48ce240c7 Make scheduled/deferred task order deterministic
Fixes #920 #1143

Explanation from @robnee on Feb 7, 2021 in pull request #927

Solvespace uses two timers (generateAllTimer and showTWTimer) to defer tasks
until the event loop processing finishes. This helps coalesce multiple calls
into one. You can call scheduleGenerateAll multiple times while processing UI
messages but only trigger one GenerateAll. scheduleGenerateAll and
scheduleShowTW do their scheuduling by setting timers with durations of zero.
These timers fire (at least on Linux and Windows) some time after all other
events in the message queue have been processed. This works fine when
scheduling either one of these tasks. However, there is no guarantee in what
order the timers will fire (at least on Windows) regardless of which order the
scheduling calls are made. It's pretty easy to demonstrate (on some platforms)
by adding logging to the scheduling calls and timer callbacks.

In many cases TextWindow::Show depends on generateAll happening first. This
causes UI glitches where displays don't update and their contents are stale.
Since this behavior is not deterministic it's easy to imagine how this problem
could make certain bug reports difficult to reproduce and diagnose. #920 is a
good example. It also makes syncing up UI behavior across all platforms a
challenge.

Solving this in the platform domain is tricky. This is PR endeavors to make the
ordering of deferred calls to TextWindow::Show and generateAll deterministic.
It does this by replacing generateAllTimer and showTWTimer with a single
refreshTimer. Calls to scheduleGenerateAll and scheduleShowTW set flags to note
the requested operations and schedule the refreshTimer. A new callback function
SolveSpaceUI::Refresh can then check the flags and ensure that generateAll
happens first. It fixes #920. Moreover, this PR makes it easy to observe and
reproduce this problem reliably and across all platforms by simply reordering
the calls in the Refresh callback.

It's pretty clear that the ordering is important so some solution is needed, if
for no other reason than the sanity of the devs. I think this is a pretty good
solution as it spells out the ordering. If nothing else this PR is helpful in
further investigations.

@ruevs @phkahler I'd like to hear your thoughts.
2022-06-14 13:07:05 -04:00
.github CI: Use upstream action to build snap & drop arm64 snap (#1232) 2022-04-12 20:12:36 -07:00
bench Refactor InitPlatform. 2020-05-10 08:29:25 +00:00
cmake MacOS: Update the year to 2022 in the About dialog. 2022-02-06 23:40:45 +02:00
developer_docs Fix various typos 2021-07-06 10:37:58 -04:00
exposed Revert "CMake: use sanitizer flags for internal targets only" 2020-10-24 17:10:47 +02:00
extlib Update mimalloc version to 2.0.6 2022-05-07 17:25:48 -04:00
include Addition of ArcLength Ratio and ArcLength Difference constraints to Constraints list 2021-06-28 11:31:53 -04:00
pkg snap: add g++ as build package (#1175) 2022-01-02 20:50:02 +01:00
res Fix Exec line of desktop files. 2022-05-17 22:09:48 -05:00
src Make scheduled/deferred task order deterministic 2022-06-14 13:07:05 -04:00
test Eigen includes are needed in more places. 2022-05-17 22:09:48 -05:00
.clang-format Modify clang-format config to avoid single-line things. NFC. 2019-09-11 09:43:03 +00:00
.gitattributes Revert "CMake: replace GetGitCommitHash with .gitattributes and $Id$." 2019-05-01 08:32:59 +00:00
.gitignore Add some gitignore stuff 2022-01-09 00:22:36 +02:00
.gitmodules Add Eigen submodule at 3.4.0 tag 2021-12-31 14:40:47 -05:00
CHANGELOG.md Update CHANGELOG.md 2022-06-02 12:14:16 -04:00
CMakeLists.txt Eigen includes are needed in more places. 2022-05-17 22:09:48 -05:00
CONTRIBUTING.md Clarify ambiguous license terms. 2021-02-25 20:37:18 -08:00
COPYING.txt Changes in preparation for the release of SolveSpace under the GPL, 2013-07-28 14:08:34 -08:00
README.md Update README.md 2022-04-01 09:20:08 -04:00
THIRD_PARTIES.txt Add a built-in Bitstream Vera Sans Roman font. 2019-02-11 11:03:47 +00:00
wishlist.txt Make oops() calls exit instead of entering debugger by default, 2011-03-05 12:52:57 -08:00

SolveSpace

SolveSpace Logo

Build Status solvespace solvespace

This repository contains the source code of SolveSpace, a parametric 2d/3d CAD.

Community

The official SolveSpace website has tutorials, reference manual and a forum; there is also an official IRC channel #solvespace at web.libera.chat.

Installation

Via Official Packages

Official release packages for macOS (>=10.6 64-bit) and Windows (>=Vista 32-bit) are available via GitHub releases. These packages are automatically built by the SolveSpace maintainers for each stable release.

Via Snap Store

Official releases can be installed from the stable channel.

Builds from master are automatically released to the edge channel in the Snap Store. Those packages contain the latest improvements, but receive less testing than release builds.

Get it from the Snap Store

Or install from a terminal:

# for the latest stable release:
snap install solvespace

# for the bleeding edge builds from master:
snap install solvespace --edge

Via automated edge builds

⚠️ Edge builds might be unstable or contain severe bugs! They are intended for experienced users to test new features or verify bugfixes.

Cutting edge builds from the latest master commit are available as zip archives from the following links:

Extract the downloaded archive and install or execute the contained file as is appropriate for your platform.

Via source code

See below.

Building on Linux

Building for Linux

You will need the usual build tools, CMake, zlib, libpng, cairo, freetype. To build the GUI, you will need fontconfig, gtkmm 3.0 (version 3.16 or later), pangomm 1.4, OpenGL and OpenGL GLU, and optionally, the Space Navigator client library. On a Debian derivative (e.g. Ubuntu) these can be installed with:

sudo apt install git build-essential cmake zlib1g-dev libpng-dev \
            libcairo2-dev libfreetype6-dev libjson-c-dev \
            libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev \
            libgl-dev libglu-dev libspnav-dev

On a RedHat derivative (e.g. Fedora) the dependencies can be installed with:

sudo dnf install git gcc-c++ cmake zlib-devel libpng-devel \
            cairo-devel freetype-devel json-c-devel \
            fontconfig-devel gtkmm30-devel pangomm-devel \
            mesa-libGL-devel mesa-libGLU-devel libspnav-devel

Before building, check out the project and the necessary submodules:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update --init extlib/libdxfrw extlib/mimalloc extlib/eigen

After that, build SolveSpace as following:

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_OPENMP=ON
make

# Optionally
sudo make install

Link Time Optimization is supported by adding -DENABLE_LTO=ON to cmake at the expense of longer build time.

The graphical interface is built as build/bin/solvespace, and the command-line interface is built as build/bin/solvespace-cli. It is possible to build only the command-line interface by passing the -DENABLE_GUI=OFF flag to the cmake invocation.

Building for Windows

Ubuntu will require 20.04 or above. Cross-compiling with WSL is also confirmed to work.

You will need the usual build tools, CMake, and a Windows cross-compiler. On a Debian derivative (e.g. Ubuntu) these can be installed with:

apt-get install git build-essential cmake mingw-w64

Before building, check out the project and the necessary submodules:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update --init

Build 64-bit SolveSpace with the following:

mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake \
            -DCMAKE_BUILD_TYPE=Release
make

The graphical interface is built as build/bin/solvespace.exe, and the command-line interface is built as build/bin/solvespace-cli.exe.

Space Navigator support will not be available.

Building on macOS

You will need git, XCode tools, CMake and libomp. Git, CMake and libomp can be installed via Homebrew:

brew install git cmake libomp

XCode has to be installed via AppStore or the Apple website; it requires a free Apple ID.

Before building, check out the project and the necessary submodules:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update --init

After that, build SolveSpace as following:

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_OPENMP=ON
make

Link Time Optimization is supported by adding -DENABLE_LTO=ON to cmake at the expense of longer build time.

Alternatively, generate an XCode project, open it, and build the "Release" scheme:

mkdir build
cd build
cmake .. -G Xcode

The application is built in build/bin/SolveSpace.app, the graphical interface executable is build/bin/SolveSpace.app/Contents/MacOS/SolveSpace, and the command-line interface executable is build/bin/SolveSpace.app/Contents/MacOS/solvespace-cli.

Building on OpenBSD

You will need git, cmake, libexecinfo, libpng, gtk3mm and pangomm. These can be installed from the ports tree:

pkg_add -U git cmake libexecinfo png json-c gtk3mm pangomm

Before building, check out the project and the necessary submodules:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update --init extlib/libdxfrw extlib/mimalloc extlib/eigen

After that, build SolveSpace as following:

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
sudo make install

Unfortunately, on OpenBSD, the produced executables are not filesystem location independent and must be installed before use. By default, the graphical interface is installed to /usr/local/bin/solvespace, and the command-line interface is built as /usr/local/bin/solvespace-cli. It is possible to build only the command-line interface by passing the -DENABLE_GUI=OFF flag to the cmake invocation.

Building on Windows

You will need git, cmake and a C++ compiler (either Visual C++ or MinGW). If using Visual C++, Visual Studio 2015 or later is required. If gawk is in your path be sure it is a proper Windows port that can handle CL LF line endings. If not CMake may fail in libpng due to some awk scripts - issue #1228.

Building with Visual Studio IDE

Check out the git submodules. Create a directory build in the source tree and point cmake-gui to the source tree and that directory. Press "Configure" and "Generate", then open build\solvespace.sln with Visual C++ and build it.

Building with Visual Studio in a command prompt

First, ensure that git and cl (the Visual C++ compiler driver) are in your %PATH%; the latter is usually done by invoking vcvarsall.bat from your Visual Studio install. Then, run the following in cmd or PowerShell:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update --init
mkdir build
cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
nmake

Building with MinGW

It is also possible to build SolveSpace using MinGW, though Space Navigator support will be disabled.

First, ensure that git and gcc are in your $PATH. Then, run the following in bash:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update --init
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Contributing

See the guide for contributors for the best way to file issues, contribute code, and debug SolveSpace.

License

SolveSpace is distributed under the terms of the GPL v3 or later.