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

Crash on simple intersections diagram, works fine in TikZ #82

Open
apetresc opened this issue Sep 24, 2024 · 4 comments
Open

Crash on simple intersections diagram, works fine in TikZ #82

apetresc opened this issue Sep 24, 2024 · 4 comments

Comments

@apetresc
Copy link

The following diagram code reliably crashes the plugin (in the sense of a real crash; the diagram spins forever to render, and then any subsequent changes to the diagram are ignored and it just hangs until I restart Obsidian):

\usepackage{tikz}
\usetikzlibrary{calc,angles,quotes,fit,intersections}
\begin{document}
\begin{tikzpicture}[thick/.style={line width=1pt},use as bounding box]
  \def\l{0.9};

  \draw[name path=circle] (0,0) coordinate(O) circle(1) {};
  \draw[name path=line] (-\l,-\l) coordinate(A)
  --(\l,-\l) coordinate(B)
  --(\l,\l)--(-\l,\l)--cycle;

  \path[name intersections={of=line and circle, by={P,Q}}];
  \fill[red] (P) circle (2pt) node[above right] {$P$};
  \fill[red] (Q) circle (2pt) node[below right] {$Q''$};

  % Add a margin of 0.2 units around each edge of the drawing
  \node[fit=(current bounding box), inner sep=0.2cm] {};
\end{tikzpicture}
\end{document}

The exact same document in a regular TikZ compiler works fine, it's quite a simple diagram. Other uses of the intersections library seem to work fine in TikZ-Mathjax and the Obsidian plugin, but there's something special about this particular one that I can't figure out, but it crashes the whole plugin 100% of the time. Hopefully this is helpful for diagnosis.

@apetresc
Copy link
Author

(I'm not sure if there's an easy way to get debug output from the plugin; I'd be happy to provide that if you point me to how)

@apetresc
Copy link
Author

By the way, I've found another diagram that uses the intersections library which also crashes the plugin:

\usepackage{tikz}
\usetikzlibrary{calc,angles,quotes,fit,intersections}
\begin{document}
\begin{tikzpicture}[thick/.style={line width=1pt},use as bounding box]
  \coordinate (A) at (0,0);
  \coordinate (D) at (4.5,0);
  \coordinate (B) at (1.35,0);
  \coordinate (P) at (2,0);
  \coordinate (Q) at (3,0);
  \coordinate (C) at (4,0);

  \draw[thick] (A)--(D);
  \draw[thick, name path=arc1] (A)--(A) arc[start angle=180, end angle=0, radius=2];
  \draw[thick, name path=arc2] (B)--(B) arc[start angle=180, end angle=0, radius=1.575];

  \path[name intersections={of=arc1 and arc2, by={R}}];

  \draw[] (A)--(R);
  \draw[] (P)--(R);
  \draw[] (Q)--(R);
  \draw[] (D)--(R);
  
  % Add a margin of 0.2 units around each edge of the drawing
  \node[fit=(current bounding box), inner sep=0.2cm] {};
\end{tikzpicture}
\end{document}

Same story, it renders fine in regular TikZ, but crashes all diagram generation in the Obsidian plugin.

I'm going to hypothesize that this happens when one of the paths being intersected is an arc/circle, rather than simple lines?

@apetresc
Copy link
Author

So I tried loading @drgrice1's fork of TikZJax directly into a browser and trying the same diagram - it also crashes. So it seems that whatever the bug is, it's not Obsidian-tikzjax-specific, it happens on the plain JS port too (though not on the native version). I guess I'll report this upstream then.

@apetresc
Copy link
Author

(And to be even more thorough, after some further investigation it seem that @kisonecat's base version does render these diagrams just fine. So actually the bug is specific to @drgrice1's fork. Possibly whatever the problem is was fixed by @kisonecat sometime in the last three years, since the fork hasn't been updated since. I guess the best thing to do would be to try to rebase drgrice1's fork onto a more recent build of kisonecat/tikzjax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant