8
$\begingroup$

The code below causes the Front End to CRASH. I came across this problem in some code that is very complicated, so I narrowed down the problem to a very simple task, to plot a couple of lines.

(* WARNING: CAUSES CRASH *)
Block[{p0 = {2, 0, 0}, seed = 2, n = 11},
 SeedRandom[seed];
 Graphics3D[{Line@
    Table[p + 3 {-0.5 + Cos[t], Sin[t], 0.5 t}
     , {p, p0 + # & /@ RandomReal[{-1, 1}, {n, 3}][[-2 ;;]]}
     , {t, -4, 4}]}
  (* no bug if PlotRange->Automatic *)
  , PlotRange -> ({# - 4.2, # + 4.2} & /@ p0)
  ]
 ]

Here's my version/system info

"14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)"

Questions:

  1. Are there any workarounds?

  2. On which systems does this problem arise?

Reported to WRI: [CASE:5121211]

Update: WRI responded with an even simpler example of the bug, which can also be avoid by using the "BSPTree" rendering engine:

Graphics3D[
 Line[{{{0, 0, -6}, {3, 0, 0}, {0, -3, 6}},{{0, 3, -6}, {-3,0,-3}}}],
 PlotRange -> {{-2, 2},{-2, 2}, {-2, 4}}] 
$\endgroup$
3
  • 2
    $\begingroup$ fyi, on V 14 on windows 10, all of Mathematica crashes and closes. Not just the front end. Using V 13.3.1 on same PC, no crash and no problems. (ps. added missing ] at end of code) $\endgroup$
    – Nasser
    Commented Mar 9 at 20:05
  • $\begingroup$ The code works fine on Mma 12.2 Windows 7 $\endgroup$
    – andre314
    Commented Mar 9 at 20:17
  • 1
    $\begingroup$ Works fine on 11.3,12.2,12.3,13.3.1 but not 14.0 $\endgroup$
    – cvgmt
    Commented Mar 10 at 1:05

1 Answer 1

4
$\begingroup$

I've found two workarounds, using a different rendering engine and mapping Line[] over the list of lists of coordinates. The first seems easiest to me from a programming viewpoint, especially if the bug is ever fixed.

Block[{p0 = {2, 0, 0}, seed = 2, n = 11},
 SeedRandom[seed];
 Graphics3D[{Line@
    Table[p + 3 {-0.5 + Cos[t], Sin[t], 0.5 t}
     , {p, p0 + # & /@ RandomReal[{-1, 1}, {n, 3}][[-2 ;;]]}
     , {t, -4, 4}]}
  (* no bug if PlotRange->Automatic *)
  , PlotRange -> ({# - 4.2, # + 4.2} & /@ p0)
  (* FIX: Graphics3DRenderingEngine *)
  , BaseStyle -> 
   RenderingOptions -> {"Graphics3DRenderingEngine" -> "BSPTree"}]
 ]

Block[{p0 = {2, 0, 0}, seed = 2, n = 11},
 SeedRandom[seed];
 Graphics3D[{Line /@ (* <-- FIX: Map *)
    Table[p + 3 {-0.5 + Cos[t], Sin[t], 0.5 t}
     , {p, p0 + # & /@ RandomReal[{-1, 1}, {n, 3}][[-2 ;;]]}
     , {t, -4, 4}]}
  (* no bug if PlotRange->Automatic *)
  , PlotRange -> ({# - 4.2, # + 4.2} & /@ p0)
  ]
 ]

I tried rewriting it as GraphicsComplex, but it crashed my front end.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.