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

bambu-studio: init at 01.06.02.04 #206495

Merged
merged 6 commits into from
Dec 10, 2023
Merged

bambu-studio: init at 01.06.02.04 #206495

merged 6 commits into from
Dec 10, 2023

Conversation

zhaofengli
Copy link
Member

@zhaofengli zhaofengli commented Dec 17, 2022

Description of changes

BambuStudio is a slicer for 3D printers made by Bambu Lab, based on PrusaSlicer.

This isn't ready to be merged yet. There are still missing functionalities in the Linux version (e.g., camera livestream) and the slicer sometimes crashes upon startup. Previously building the package with libraries shipped by Nixpkgs required some invasive patches which have since been merged. Upstream has promised better Linux support so let's wait a bit. (camera stream is now working and slicer no longer crashes intermittently)

The last commit is bandaid from #206221. I will remove it once the mpfr fixes land in master. (done)

Ref: bambulab/BambuStudio#12

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Dec 17, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 17, 2022
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-linux: 1 labels Dec 21, 2022
@zhaofengli zhaofengli changed the title bambu-studio: init at unstable-2022-12-16 bambu-studio: init at unstable-2023-01-11 Jan 17, 2023
@zhaofengli
Copy link
Member Author

Thanks to the amazing work by @jwise in bambulab/BambuStudio#1053 and bambulab/BambuStudio#1045, we can use the EGL-enabled version of wxWidgets and the camera stream is now working. I've also added a fix for the intermittent crash and this seems ready to be merged.

@zhaofengli zhaofengli marked this pull request as ready for review January 17, 2023 21:29
@jwise
Copy link

jwise commented Jan 17, 2023

@zhaofengli What's the intermittent crash fix? I know there's at least one I've been tracking. Should we upstream it?

@zhaofengli
Copy link
Member Author

It's not actually a fix but kind of an ugly workaround.

For some reason, glew sometimes isn't initialized correctly and __glewGenBuffers is NULL. We link dynamically in nixpkgs - The upstream setup links statically which doesn't seem to cause issues.

It dies here (see backtrace below):

   0x0000000000f1e6b9 <+25>:    push   %rbx
   0x0000000000f1e6ba <+26>:    mov    %rsi,%rbx
   0x0000000000f1e6bd <+29>:    lea    0x4(%rsi),%rsi
   0x0000000000f1e6c1 <+33>:    call   *(%r14)
=> 0x0000000000f1e6c4 <+36>:    mov    0xf7f4fd(%rip),%rbp        # 0x1e9dbc8
   0x0000000000f1e6cb <+43>:    mov    0x4(%rbx),%esi
   0x0000000000f1e6ce <+46>:    mov    $0x8892,%edi
(gdb) x $r14
0x7ffff0f12bf8 <__glewGenBuffers>:      0x00000000
Backtrace of segfault

At this point wxGetApp().init_opengl() was just called (see frame 8).

#0  0x0000000000000000 in ?? ()
#1  0x0000000000f1e6c4 in Slic3r::GUI::GLModel::send_to_gpu (this=<optimized out>, data=..., 
    vertices=std::vector of length 900, capacity 900 = {...}, indices=std::vector of length 150, capacity 150 = {...})
    at /build/source/src/slic3r/GUI/GLModel.cpp:315
#2  0x0000000000f1eb94 in Slic3r::GUI::GLModel::init_from (this=0x4603560, its=..., bbox=...)
    at /build/source/src/slic3r/GUI/GLModel.cpp:106
#3  0x0000000000f1f441 in Slic3r::GUI::GLModel::init_from (this=this@entry=0x4603560, its=...)
    at /build/source/src/slic3r/GUI/GLModel.cpp:112
#4  0x0000000000eb0faa in Slic3r::GUI::GLGizmoBase::GLGizmoBase (this=this@entry=0x4603490, parent=..., icon_filename="toolbar_move.svg", 
    sprite_id=sprite_id@entry=0) at /build/source/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp:164
#5  0x0000000000eb24bf in Slic3r::GUI::GLGizmoMove3D::GLGizmoMove3D (this=this@entry=0x4603490, parent=..., 
    icon_filename="toolbar_move.svg", sprite_id=sprite_id@entry=0, obj_manipulation=obj_manipulation@entry=0x37ddfb0)
    at /build/source/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp:32
#6  0x0000000000ea7365 in Slic3r::GUI::GLGizmosManager::init (this=this@entry=0x37ddda8)
    at /build/source/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp:189
#7  0x0000000000e7503c in Slic3r::GUI::GLCanvas3D::init (this=0x37ddc00) at /build/source/src/slic3r/GUI/GLCanvas3D.cpp:1220
#8  0x0000000000fa2202 in Slic3r::GUI::GUI_App::post_init (this=0x24505e0) at /build/source/src/slic3r/GUI/GUI_App.cpp:1025
#9  0x00007ffff0d30e96 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#10 0x00007ffff0d311d6 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#11 0x00007ffff0d31340 in wxEvtHandler::TryHereOnly(wxEvent&) ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#12 0x00007ffff0d313eb in wxEvtHandler::ProcessEventLocally(wxEvent&) ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#13 0x00007ffff0d31491 in wxEvtHandler::ProcessEvent(wxEvent&) ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#14 0x00007ffff0c150f8 in wxAppConsoleBase::ProcessIdle() ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#15 0x00007ffff07d7724 in wxAppBase::ProcessIdle() ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_gtk3u_core-3.1.so.5
#16 0x00007ffff0717aa9 in wxApp::DoIdle() ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_gtk3u_core-3.1.so.5
#17 0x00007ffff0717b83 in wxapp_idle_callback ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_gtk3u_core-3.1.so.5
#18 0x00007fffee06a8e4 in g_main_context_dispatch () from /nix/store/61qy7d70070djqcg135l22v18a5py758-glib-2.74.3/lib/libglib-2.0.so.0
#19 0x00007fffee06ac88 in g_main_context_iterate.constprop ()
   from /nix/store/61qy7d70070djqcg135l22v18a5py758-glib-2.74.3/lib/libglib-2.0.so.0
#20 0x00007fffee06af73 in g_main_loop_run () from /nix/store/61qy7d70070djqcg135l22v18a5py758-glib-2.74.3/lib/libglib-2.0.so.0
#21 0x00007fffee9c23c5 in gtk_main () from /nix/store/rv6nydaizz3n8s3l3jv6pss0pzxn3yzm-gtk+3-3.24.35/lib/libgtk-3.so.0
#22 0x00007ffff0727c65 in wxGUIEventLoop::DoRun() ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_gtk3u_core-3.1.so.5
#23 0x00007ffff0c3f37d in wxEventLoopBase::Run() ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#24 0x00007ffff0c1491b in wxAppConsoleBase::MainLoop() ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#25 0x00007ffff0c81eb6 in wxEntry(int&, wchar_t**) ()
   from /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5/lib/libwx_baseu-3.1.so.5
#26 0x0000000000f6e46b in Slic3r::GUI::GUI_Run (params=...) at /build/source/src/slic3r/GUI/GUI_Init.cpp:64
#27 0x00000000007a8f1b in Slic3r::CLI::run (this=0x7fffffffb9c0, argc=<optimized out>, argv=<optimized out>)
    at /build/source/src/BambuStudio.cpp:452
#28 0x0000000000763255 in main (argc=<optimized out>, argv=<optimized out>) at /build/source/src/BambuStudio.cpp:2625

@jwise
Copy link

jwise commented Jan 18, 2023

Oh, this is the crash where things go wrong if the window doesn't have focus?

You definitely should not be linking dynamically against an external GLEW, unless you are specifying that it is an EGL GLEW (or that the EGLness of the GLEW, anyway, is the same as the EGLness of the wxWidgets). GLEW can either be built as EGL or GLX, but not both at the same time. It is much better to use the vendored GLEW, for this reason.

Note also that if you are linking against an external wxWidgets, there are at least some BBS-specific patches to wxWidgets in their tree, too, which is why they build that statically...

@zhaofengli
Copy link
Member Author

zhaofengli commented Jan 18, 2023

This package is indeed specified to use the EGL version of GLEW and a special version of wxWidgets with WebRequests and private fonts enabled.1 When you specify a dependency, the resulting executables have their runpaths pinned to that specific version of dependency (e.g., /nix/store/83gnq2f6h1jw2n7fndjjfgf50gf4894i-wxwidgets-3.1.5). Everything is pinned and global libraries simply do not exist (no /lib or /usr/lib).

You can curl.overrideAttrs ({ patches ? [], ... }: { patches = patches ++ [ ./my.patch ]; }) and it evaluates to a patched version of curl that gets installed to a path that doesn't affect any other curl in the system. It's all functional and I invite you to give it a try 😄

Because each build happens in a clean sandbox without network access, it's difficult to use the vendored deps and we generally avoid doing so unless necessary. Regarding the wxWidgets patches, I don't immediately see a need from a quick glance but if we do, we can easily add them (see example above).

Footnotes

  1. Yes, I do need to remove the commented out withEGL = false override...

@norpol
Copy link
Contributor

norpol commented Feb 22, 2023

I'm running on latest nixos-unstable and I'm building/launching bambu-studio via

nix shell github:zhaofengli/nixpkgs/bambu-studio#bambu-studio
bambu-studio

Which starts-up (flashes open on my screen) and then crashes in the same moment.

As you might see on the video recording, you notice that the UI almost presents completely up until around these errors:
screencast.webm

(bambu-studio:8781): Gtk-CRITICAL **: 16:38:44.084: gtk_widget_set_size_request: assertion 'width >= -1' failed
libEGL warning: MESA-LOADER: failed to open radeonsi: /nix/store/wprxx5zkkk13hpj6k1v6qadjylh3vq9m-gcc-11.3.0-lib/lib/libstdc++.so.6: version
`GLIBCXX_3.4.30' not found (required by /nix/store/yvcnhajqbwcq35vpnsm1waw557dxcn5v-llvm-15.0.7-lib/lib/libLLVM-15.so) (search paths /run/ope
ngl-driver/lib/dri, suffix _dri)

libEGL warning: MESA-LOADER: failed to open swrast: /nix/store/wprxx5zkkk13hpj6k1v6qadjylh3vq9m-gcc-11.3.0-lib/lib/libstdc++.so.6: version `G
LIBCXX_3.4.30' not found (required by /nix/store/yvcnhajqbwcq35vpnsm1waw557dxcn5v-llvm-15.0.7-lib/lib/libLLVM-15.so) (search paths /run/openg
l-driver/lib/dri, suffix _dri)

EGLDisplay Initialization failed: EGL_NOT_INITIALIZED
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)

(bambu-studio:8781): Gtk-CRITICAL **: 16:38:44.229: gtk_gesture_zoom_new: assertion 'GTK_IS_WIDGET (widget)' failed

@norpol
Copy link
Contributor

norpol commented Mar 2, 2023

I've rebased your branch to latest nixos-unstable and added some gcc-unwrapped as a dependency which is similarish to here, not sure if that was the cause but it builds now.

Also since they've just released the 1.5 Beta version, I gave building this a shot and it seems to be working. 86286f4

Only issue right now is the error "Media playback error: Could not open audio device for playback." when I'm trying to start the webcam.

2023-03-02-151449

@zhaofengli
Copy link
Member Author

I've rebased your branch to latest nixos-unstable and added some gcc-unwrapped as a dependency which is similarish to here, not sure if that was the cause but it builds now.

Also since they've just released the 1.5 Beta version, I gave building this a shot and it seems to be working. 86286f4

Thanks! I've added the fix to the PR and bumped the version.

Only issue right now is the error "Media playback error: Could not open audio device for playback." when I'm trying to start the webcam.

Hmm, everything seems to be working fine for me with Pipewire.

@norpol
Copy link
Contributor

norpol commented Mar 6, 2023

Awesome and thank you, I've re-built your changes and everything works as expected.

I could strace/tackle down the issue with "Could not open audio device for playback.", somehow bambu-studio tries to interact with alsa, I haven't had services.pipewire.alsa.enable = true; yet (since no other application needed this so far) and now video playback works. Since they don't have actual audio playback I assume it's a bug in the gstreamer invocation in bambu-studio.

Can we add alsa/pipewire-alsa as a dependency/suggestion to this package until they've resolved their issues?

What's the remaining to-do for your pull request?

I primarily understand that withEGL = false should be changed?

Do you need any support?

Update: Opened an issue upstream bambulab/BambuStudio#1426

@norpol
Copy link
Contributor

norpol commented Mar 7, 2023

I've also built https://github.com/SoftFever/BambuStudio-SoftFever, which supports other printers + several calibration gcode generators.

Might also be worth packaging the @SoftFever version as it looks quite useful.

There is a known bug showing up, that's also affecting their app-image version and I've created a separate report for that SoftFever/OrcaSlicer#442

diff --git a/pkgs/applications/misc/bambu-studio/default.nix b/pkgs/applications/misc/bambu-studio/default.nix
index 5ffceb22fd..acb2a0fb8b 100644
--- a/pkgs/applications/misc/bambu-studio/default.nix
+++ b/pkgs/applications/misc/bambu-studio/default.nix
@@ -50,14 +50,15 @@ let
   });
 in
 stdenv.mkDerivation rec {
-  pname = "bambu-studio";
-  version = "01.05.00.59";
+  pname = "bambu-studio-softfever";
+  version = "1.4.5";

   src = fetchFromGitHub {
-    owner = "bambulab";
-    repo = "BambuStudio";
+    owner = "softfever";
+    repo = "BambuStudio-SoftFever";
     rev = "v${version}";
-    hash = "sha256-NCd2hT6xVaTySYkacAV1wT1fOe8yq4qPxmEzUdVHEDw=";
+    hash = "sha256-jwtYzcDQb3LpABf8btgiKRuLPUMhrDTRE/lqtaTgGU4=";
   };

   nativeBuildInputs = [
@@ -158,7 +159,7 @@ stdenv.mkDerivation rec {

   meta = with lib; {
     description = "PC Software for BambuLab's 3D printers";
-    homepage = "https://github.com/bambulab/BambuStudio";
+    homepage = "https://github.com/SoftFever/BambuStudio-SoftFever";
     license = licenses.agpl3;
     maintainers = with maintainers; [ zhaofengli ];
     mainProgram = "bambu-studio";
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 255e4b0a69..c1528d4f7d 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -33244,7 +33244,7 @@ with pkgs;

   super-slicer-latest = super-slicer.latest;

-  bambu-studio = callPackage ../applications/misc/bambu-studio {
+  bambu-studio-softfever = callPackage ../applications/misc/bambu-studio {
     inherit (gst_all_1) gstreamer gst-plugins-base gst-plugins-bad;

     # Needs to be the same version as in the closed-source networking plugin.

@deftdawg
Copy link
Contributor

Random chime in... (I'm a nixOS noob, so this may not be helpful)

I installed this on 22.11 via:

export REV=6b1493ed77d54947f043d30f1960ed343d90ca50
nix --extra-experimental-features flakes profile install --impure github:zhaofengli/nixpkgs/${REV}#bambu-studio

# Run it with LC_ALL or it will crash
LC_ALL=C bambu-studio

It starts to init, and then coredumps... maybe it's because I'm running X11 instead of Wayland or something, could also be upstream bug... anywhere here's a backtrace

Thread 40 "bambu-stud:sh0" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff57fff640 (LWP 253620)]
0x00007fffde493b40 in llvm::MachinePointerInfo::getAddrSpace() const () from /nix/store/1a31x70as21dm8dbl25h1qqvy5if4qsi-llvm-15.0.7-lib/lib/libLLVM-15.so
(gdb) bt
#0  0x00007fffde493b40 in llvm::MachinePointerInfo::getAddrSpace() const () from /nix/store/1a31x70as21dm8dbl25h1qqvy5if4qsi-llvm-15.0.7-lib/lib/libLLVM-15.so
#1  0x00007fffde9c0a0a in AddNodeIDCustom(llvm::FoldingSetNodeID&, llvm::SDNode const*) () from /nix/store/1a31x70as21dm8dbl25h1qqvy5if4qsi-llvm-15.0.7-lib/lib/libLLVM-15.so
#2  0x00007fffde9c0f54 in llvm::FoldingSet<llvm::SDNode>::NodeEquals(llvm::FoldingSetBase const*, llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) ()
   from /nix/store/1a31x70as21dm8dbl25h1qqvy5if4qsi-llvm-15.0.7-lib/lib/libLLVM-15.so
#3  0x00007fff5d9c09ab in llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&, llvm::FoldingSetBase::FoldingSetInfo const&) ()
   from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#4  0x00007fff5d9c0a90 in llvm::FoldingSetBase::GetOrInsertNode(llvm::FoldingSetBase::Node*, llvm::FoldingSetBase::FoldingSetInfo const&) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#5  0x00007fff5e4316e3 in llvm::SelectionDAG::AddModifiedNodeToCSEMaps(llvm::SDNode*) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#6  0x00007fff5e431eaa in llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDValue, llvm::SDValue) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#7  0x00007fff5e2dbcec in (anonymous namespace)::SelectionDAGLegalize::ReplaceNode(llvm::SDValue, llvm::SDValue) [clone .constprop.0] () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#8  0x00007fff5e2f35b5 in llvm::SelectionDAG::Legalize() () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#9  0x00007fff5e464af3 in llvm::SelectionDAGISel::CodeGenAndEmitDAG() () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#10 0x00007fff5e4677fc in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#11 0x00007fff5e46a012 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) [clone .part.0] () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#12 0x00007fff5def2d97 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#13 0x00007fff5dc1fc30 in llvm::FPPassManager::runOnFunction(llvm::Function&) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#14 0x00007fff5f267eca in (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#15 0x00007fff5dc21634 in llvm::legacy::PassManagerImpl::run(llvm::Module&) () from /nix/store/gaamqa1p6ql40y80d18rpd2q6xi6w7hn-llvm-14.0.6-lib/lib/libLLVM-14.so
#16 0x00007fff712e2206 in ac_compile_module_to_elf () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#17 0x00007fff712336e1 in si_compile_llvm () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#18 0x00007fff71235e9c in si_llvm_compile_shader () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#19 0x00007fff7123024e in si_compile_shader () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#20 0x00007fff71256e1d in si_init_shader_selector_async(void*, void*, int) () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#21 0x00007fff70ab7099 in util_queue_thread_func () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#22 0x00007fff70b020c7 in impl_thrd_routine () from /run/opengl-driver/lib/dri/radeonsi_dri.so
#23 0x00007fffe9688e86 in start_thread () from /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/libc.so.6
#24 0x00007fffe970fd30 in clone3 () from /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/libc.so.6

@deftdawg
Copy link
Contributor

Maybe a false alarm, I think the issue is to do with how I'm flaking stuff in my profile...

I just built realthunder's freecad in a similar manner using nix profile install and it also crashes, must be my bad.

@norpol
Copy link
Contributor

norpol commented Mar 21, 2023

@deftdawg Try the nix shell I've provided (Sorry might rebuild everything). Also (I'm not sure) but might be an issue with the mismatch between unstable vs 22.11. Also might be related to an outdated nix profile? At least back when nix-env -iA was still a thing you'd run into similar issues frequently.

nix shell github:zhaofengli/nixpkgs/bambu-studio#bambu-studio
bambu-studio

@deftdawg
Copy link
Contributor

@deftdawg Try the nix shell I've provided (Sorry might rebuild everything). Also (I'm not sure) but might be an issue with the mismatch between unstable vs 22.11. Also might be related to an outdated nix profile? At least back when nix-env -iA was still a thing you'd run into similar issues frequently.

nix shell github:zhaofengli/nixpkgs/bambu-studio#bambu-studio
bambu-studio

Thanks @norpol. Result is the same, it's probably something with my setup...

The nix store artifact is the same when I build it through nix install profile or nix shell, maybe because it's cached...

In both cases it uses this:
/nix/store/ppiyw7yyfgh67yfb83z1ay9jcy1gymyx-bambu-studio-01.05.00.59/bin/bambu-studio

Is that the same hash you have for it?

@norpol
Copy link
Contributor

norpol commented Mar 21, 2023

@deftdawg /nix/store/ppiyw7yyfgh67yfb83z1ay9jcy1gymyx-bambu-studio-01.05.00.59/ same path indeed.

@deftdawg
Copy link
Contributor

@norpol here's the LC_ALL=C strace -f -s1024 .bambu-studio-wrapped 2&> ~/bambu-studio-playbin-strace.txt

bambu-studio-playbin-strace.txt.gz

When I run the wrapper, it paints the following... perhaps it can't find gstreamer or the network plugin.
Screenshot_20230321_202022

@deftdawg
Copy link
Contributor

deftdawg commented Mar 26, 2023

I built Zhaofengli's older bambu-studio-old tag

export REV=b9f18ffc3489fc926843a4b64d9fae79ddee8aa8
nix --extra-experimental-features flakes profile install --impure github:zhaofengli/nixpkgs/${REV}#bambu-studio
bambu-studio 

It still gives the same error message about invalid playbin, however it does not segfault... So I'm using that for now.

@aacebedo
Copy link
Contributor

aacebedo commented Nov 5, 2023

I updated my system a couple of days ago, I hand't tried to start bambu-studio since, just tried it now, and I am also getting a segmentation fault. Although I am still on BambuStudio-01.07.00.65.

I tried 01.07.06.92 same issue. Plus the fact that on Hyprland it just closes itself immediately (no segfault).

@noisersup
Copy link
Member

The same segfault issue after the update, both on wayland, and x11.

@aacebedo
Copy link
Contributor

aacebedo commented Nov 5, 2023

The same segfault issue after the update, both on wayland, and x11.

Also tried the other PR for orca slicer. Same issue.

@noisersup
Copy link
Member

Okay, got some time and tried to obtain a bit more information.

Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)
Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)

Those logs print out in my latest (updated) NixOS generation, while the old, working one doesn't print those. Maybe it's related to Glib which bumped version in the meantime?

@norpol
Copy link
Contributor

norpol commented Nov 11, 2023

Yes, it's likely the glibc version. Starting with --debug 5 will show some glibc related error messages. I've rebased and switched to the latest beta release (1.8.0), but that now fails because of changes in tbb and wxGTK. Starting point might be prusa-slicer which incorporates some patches to support wxGTK32 patches.

With glibc updated, tbb newer and openvdb related to that I get till (diff).

Found also another issue with the same error prusa3d/PrusaSlicer#9294

which probably talks about this gentoo prusaslicer boost patch. Nah the boost patch doesn't do the job and no idea who is calling wXCStrData lol.

include/boost/filesystem/detail/path_traits.hpp:495: error: call of overloaded '_check_convertible_to_path_source(const wxCStrData&)' is ambiguous

I'm not sure if just that patch will do the job, the prusa-slicer has no boost patch but instead patches wxGTK32 to be compatible.

https://github.com/NixOS/nixpkgs/blob/f2bd8adf7b78d7616b52d0ef08865c7c2fcf189d/pkgs/applications/misc/prusa-slicer/default.nix#L147C46-L152

@deftdawg
Copy link
Contributor

Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)
Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)

I've upgrade to 23.11/Unstable (needed to move up to keep Jovian-NixOS working 😄 ) and I get the above as well with the window opening and then crashing... Put gdb on it and captured this backtrace of the segfault happening at ImFont::CalcTextSizeA.

echo -e "run\nbt\n\n" | LC_ALL=C gdb ./bambu-studio
...
Thread 1 "bambustu_main" received signal SIGSEGV, Segmentation fault.
0x0000000001c8cf13 in ImFont::CalcTextSizeA(float, float, float, char const*, char const*, char const**) const ()
(gdb) bt
#0  0x0000000001c8cf13 in ImFont::CalcTextSizeA(float, float, float, char const*, char const*, char const**) const ()
#1  0x0000000001c42bd3 in ImGui::CalcTextSize(char const*, char const*, bool, float) ()
#2  0x0000000001699304 in Slic3r::GUI::NotificationManager::HintNotification::count_spaces() ()
#3  0x000000000169940b in Slic3r::GUI::NotificationManager::HintNotification::init() ()
#4  0x00000000016a279a in Slic3r::GUI::NotificationManager::HintNotification::retrieve_data(bool) ()
#5  0x0000000001456b27 in Slic3r::GUI::NotificationManager::push_hint_notification(bool) ()
#6  0x000000000110cc6b in Slic3r::GUI::GUI_App::post_init() ()
#7  0x000000000110f0fd in Slic3r::GUI::GUI_App::on_init_inner()::{lambda(wxIdleEvent&)#6}::operator()(wxIdleEvent&) const [clone .constprop.0] ()
#8  0x00007ffff0bbfd12 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#9  0x00007ffff0bc0047 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#10 0x00007ffff0bc01b0 in wxEvtHandler::TryHereOnly(wxEvent&) () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#11 0x00007ffff0bc025a in wxEvtHandler::ProcessEventLocally(wxEvent&) () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#12 0x00007ffff0bc0301 in wxEvtHandler::ProcessEvent(wxEvent&) () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#13 0x00007ffff0aa29d2 in wxAppConsoleBase::ProcessIdle() () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#14 0x00007ffff060e454 in wxAppBase::ProcessIdle() () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_gtk3u_core-3.1.so.7
#15 0x00007ffff054cc9a in wxApp::DoIdle() () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_gtk3u_core-3.1.so.7
#16 0x00007ffff054cd73 in wxapp_idle_callback () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_gtk3u_core-3.1.so.7
#17 0x00007fffede1cc4f in g_main_context_dispatch () from /nix/store/fr53rm643lg0rp4qmgzzpwsz5xxdqwk0-glib-2.76.3/lib/libglib-2.0.so.0
#18 0x00007fffede1d028 in g_main_context_iterate.constprop () from /nix/store/fr53rm643lg0rp4qmgzzpwsz5xxdqwk0-glib-2.76.3/lib/libglib-2.0.so.0
#19 0x00007fffede1d2df in g_main_loop_run () from /nix/store/fr53rm643lg0rp4qmgzzpwsz5xxdqwk0-glib-2.76.3/lib/libglib-2.0.so.0
#20 0x00007fffee605d75 in gtk_main () from /nix/store/9f63g8hd0f2iyxzpw41jrr9qqqhcfdab-gtk+3-3.24.38/lib/libgtk-3.so.0
#21 0x00007ffff055d8e5 in wxGUIEventLoop::DoRun() () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_gtk3u_core-3.1.so.7
#22 0x00007ffff0acc6fd in wxEventLoopBase::Run() () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#23 0x00007ffff0aa221b in wxAppConsoleBase::MainLoop() () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#24 0x00007ffff0b0d8f7 in wxEntry(int&, wchar_t**) () from /nix/store/rqqa7v39hzy4ppvjw9iqqsqr3i9g87q1-wxwidgets-3.1.7/lib/libwx_baseu-3.1.so.7
#25 0x00000000010d40ab in Slic3r::GUI::GUI_Run(Slic3r::GUI::GUI_InitParams&) ()
#26 0x000000000083b54b in Slic3r::CLI::run(int, char**) ()
#27 0x00000000007e04f4 in main ()

wxGTK31 = wxGTK31.override {
withCurl = true;
withPrivateFonts = true;
withWebKit = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With wxGTK32 withWebKit=true; will be default from now on

https://github.com/NixOS/nixpkgs/pull/268348/files

@norpol
Copy link
Contributor

norpol commented Nov 25, 2023

@deftdawg Did you get it running already?

Seems to be a bug that was reported in PursaSlicer too.

prusa3d/PrusaSlicer#9774

@norpol
Copy link
Contributor

norpol commented Nov 26, 2023

After way too many weekends working on this I finally got it to compile:

  • wxGTK31
  • boost179
  • bambu-studio 01.08.00.62
  • opvdb & tbb at 2021

Here is my branch zhaofengli#2

* Switch to newer tbb version

tbb was broken up into two versions for backwards compability

https://github.com/NixOS/nixpkgs/pull/217585/files

and put into prusa-slicer

https://github.com/NixOS/nixpkgs/pull/238921/files

Which fixes for 1.8 beta build
```
bambu-studio> CMake Error at src/libslic3r/CMakeLists.txt:490 (target_link_libraries):
bambu-studio>   Target "libslic3r" links to:
bambu-studio>     TBB::tbbmalloc
bambu-studio>   but the target was not found.  Possible reasons include:
bambu-studio>     * There is a typo in the target name.
bambu-studio>     * A find_package call is missing for an IMPORTED target.
bambu-studio>     * An ALIAS target is missing.
bambu-studio>
bambu-studio> -- Generating done (0.2s)
bambu-studio> CMake Warning:
bambu-studio>   Manually-specified variables were not used by the project:
bambu-studio>     CMAKE_EXPORT_NO_PACKAGE_REGISTRY
bambu-studio>     DEP_WX_GTK3
bambu-studio>
bambu-studio> CMake Generate step failed.  Build files cannot be regenerated correctly.
error: builder for '/nix/store/rzgx01p1ni2xbx5ddg0133pjjlzs8618-bambu-studio-01.08.00.57.drv' failed with exit code 1;
```

* bambu-studio: switch to custom openvdb tbb version

* Downgrade boost to 179 (181 is current default)
@deftdawg
Copy link
Contributor

@deftdawg Did you get it running already?

Hi @norpol, my home Internet's been offline all weekend, just got back online and tried with your PR merged into @zhaofengli fork. Works 100%, thank you for pushing up that fix. 🍻

@Wulfsta
Copy link
Member

Wulfsta commented Dec 10, 2023

Now that this is building, all checks are passing, and users are reporting that it's working, can a maintainer with permissions merge it? It would be great to have some movement on this since #239390, the package request for OrcaSlicer, depends on it.

@deftdawg
Copy link
Contributor

I think it's okay to merge in its current state, though it'd be good to have the edit filaments crash (mentioned above) fixed upstream.

That being said I can't see why merging orcaslicer would depend on this...

@cab404
Copy link
Member

cab404 commented Dec 10, 2023

Will build and test in slicing, and then merge.

@norpol
Copy link
Contributor

norpol commented Dec 10, 2023

OrcaSlicer builds and works with this current PR (just need to point the package to OrcaSlicer). OrcaSlicer already fixed the "Edit Filament" bug and as of latest beta release of BambuStudio they've also pulled in that fix (fix number 17 at the release notes).

I'd suggest to wait for the final 01.08 release and then finally merge.

bambulab/BambuStudio#2605 (comment)

https://github.com/bambulab/BambuStudio/releases/tag/v01.08.01.57

@cab404
Copy link
Member

cab404 commented Dec 10, 2023

OrcaSlicer builds and works with this current PR (just need to point the package to OrcaSlicer). OrcaSlicer already fixed the "Edit Filament" bug and as of latest beta release of BambuStudio they've also pulled in that fix (fix number 17 at the release notes).

I'd suggest to wait for the final 01.08 release and then finally merge.

bambulab/BambuStudio#2605 (comment)

https://github.com/bambulab/BambuStudio/releases/tag/v01.08.01.57

We will always be able to merge it afterwards.

@cab404
Copy link
Member

cab404 commented Dec 10, 2023

Yup, everything builds and appears to be working in current state. Merging <3

@cab404 cab404 merged commit 92ec31f into NixOS:master Dec 10, 2023
22 checks passed
@cab404
Copy link
Member

cab404 commented Dec 10, 2023

OrcaSlicer builds and works with this current PR (just need to point the package to OrcaSlicer). OrcaSlicer already fixed the "Edit Filament" bug and as of latest beta release of BambuStudio they've also pulled in that fix (fix number 17 at the release notes).

I'd suggest to wait for the final 01.08 release and then finally merge.

bambulab/BambuStudio#2605 (comment)

https://github.com/bambulab/BambuStudio/releases/tag/v01.08.01.57

But yeah, edit filament is unfortunate

@cab404
Copy link
Member

cab404 commented Dec 10, 2023

Will bump to 57, and then let's re-check it

@cab404
Copy link
Member

cab404 commented Dec 10, 2023

#273350

JohnRTitor pushed a commit that referenced this pull request Jun 20, 2024
* wxGTK31: Support enabling WebRequest component

* wxGTK31: Support enabling private fonts

* bambu-studio: init at 01.06.02.04

Co-authored-by: Phileas Lebada <[email protected]>

* bambu-studio: 01.06.02.04 -> 01.07.00.65

* bambu-studio: 01.07.00.65 -> 01.07.06.92

The OpenSSL pin is no longer needed.

* bambu-studio: 01.07.06.92 -> 01.08.00.62

* Switch to newer tbb version

tbb was broken up into two versions for backwards compability

https://github.com/NixOS/nixpkgs/pull/217585/files

and put into prusa-slicer

https://github.com/NixOS/nixpkgs/pull/238921/files

Which fixes for 1.8 beta build
```
bambu-studio> CMake Error at src/libslic3r/CMakeLists.txt:490 (target_link_libraries):
bambu-studio>   Target "libslic3r" links to:
bambu-studio>     TBB::tbbmalloc
bambu-studio>   but the target was not found.  Possible reasons include:
bambu-studio>     * There is a typo in the target name.
bambu-studio>     * A find_package call is missing for an IMPORTED target.
bambu-studio>     * An ALIAS target is missing.
bambu-studio>
bambu-studio> -- Generating done (0.2s)
bambu-studio> CMake Warning:
bambu-studio>   Manually-specified variables were not used by the project:
bambu-studio>     CMAKE_EXPORT_NO_PACKAGE_REGISTRY
bambu-studio>     DEP_WX_GTK3
bambu-studio>
bambu-studio> CMake Generate step failed.  Build files cannot be regenerated correctly.
error: builder for '/nix/store/rzgx01p1ni2xbx5ddg0133pjjlzs8618-bambu-studio-01.08.00.57.drv' failed with exit code 1;
```

* bambu-studio: switch to custom openvdb tbb version

* Downgrade boost to 179 (181 is current default)

---------

Co-authored-by: Phileas Lebada <[email protected]>
(cherry picked from commit 92ec31f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.