davfive / obsidian-jtab

jTab Guitar Codeblocks for Obsidian adds the ability to show guitar chords and tabs directly in your notes.
MIT License
65 stars 1 forks source link

jTab possibly breaking taitava/obsidian-shellcommands (disappearing shell commands) #15

Closed davfive closed 4 months ago

davfive commented 4 months ago

Raised by @taitava via email to me

From the email thread @dokmanc has the same problem, too: #351 (And I never actually got to inspect the problem much, so I still do not have any solutions).

Error in Obsidian console: Step 4:

app.js:1 Error: Plugin "obsidian-jtab" is not passing Component in renderMarkdown. This is needed to avoid memory leaks when embedded contents register global event handlers.
at t.render (app.js:1:1276278)
at t.renderMarkdown (app.js:1:1276059)
at Il.display (plugin:obsidian-jtab:249:2362)
at t.openTab (app.js:1:2741344)
at HTMLDivElement. (app.js:1:2739783)
I'm not certain about this problem, but I guess it's not actually causing these bugs. It might be just some unrelated other issue with jTab? But I'm not 100 % sure this doesn't cause the actual problem.

Step 5:

plugin:obsidian-shellcommands:15606 Uncaught TypeError: tab_content.removeClass is not a function
at button.onclick (plugin:obsidian-shellcommands:15606:29)
at createTabs (plugin:obsidian-shellcommands:15648:32)
at SC_MainSettingsTab.display (plugin:obsidian-shellcommands:16620:30)
at t.openTab (app.js:1:2741344)
at HTMLDivElement. (app.js:1:2739783)

I installed the jTab plugin now and was able to reproduce the tab_content.removeClass is not a function error.

I also happened to have a shell command executing via events which outputs text to statusbar, and it has the following error: kuva.png (view on web) I suspect that this is also caused by some incompatibility with jTab, as disabling jTab and restarting Obsidian prevented this problem from happening.

I tried to glance through the source code of the jTab plugin quickly, but didn't have enough time to find out anything suspicious. Also, the problem could be in one of the libraries the plugin is using. I'm suspecting that something tampers with global HTMLElement and String objects, as those seem to be missing methods that should normally be available. This is just my guessing, as I didn't go far with my inspections.

The jTab plugin also has this issue mentioning another plugin that suffers from this problem: davfive/obsidian-jtab#10

I thought I'd open up an issue in the jTab plugin's repository myself, too, but I don't have much time now, and also as I think there's already valuable information in this discussion, I'll invite the jTab plugin's author to this discussion. Hello, @davfive ! πŸ™‚ Do you have some opinions on how to go forward with this incompatibility problem? πŸ™‚ I don't have much time to inspect the jTab plugin's source code myself, but if there's anything I can do on my plugin's side, please let me know. πŸ‘

davfive commented 4 months ago

No root cause determined yet

I have isolated where

I tried not loading jtab.tardate.js and raphael ... and shellcommands started working again. Now I just have to figure out what specifically is causing the problem so here's my research so far ...

I have ruled out

  1. "Error: Plugin "obsidian-jtab" is not passing Component in renderMarkdown"

    I am aware of this error, and the reason (I knowingly released it that way) That error is caused because I wanted to have my help content in the settings page so I render markdown on the settings page. However, Obsidian complains when you render outside of a component (and I don't have one to pass because I am in settings). I always meant to get back to it to see if there was a way to auto-trigger the cleanup - I do detect when someone leaves the settings page because that's when I save the changes.

  2. jtab.tardate.js (original library) using jQuery (loading globally)

    I refacted the original tardate code to remove the jQuery (in case it was stomping on someone elses version). No joy.

  3. jtab.tardate.js (original library) playing tricks with window.onload

    I normalized jtab.tardate.js's use of window.onload. No luck

  4. wrapping jtab.tardate.js properly with the module pattern (anonymous function + limited exports)

    I was hopeful, but this didn't work 😦

Next things to try (not today, I do have to get enough sleep tonight to be present for work tomorrow)

  1. Have jtab.tardate.js stop importing raphael.
  2. Wrap raphael in an anonymous function (I've actually done this a little bit, but I don't think it was fully successful.
  3. Look through raphael code to see if they are doing anything weird.
  4. Sleep on it and see if I have any better ideas tomorrow.
davfive commented 4 months ago

Referenced in obsidian-shellcommands #351 discussion

davfive commented 4 months ago

This weekends attempt is to convert the old jtab code to typescript and compile it directly into my plugin. I'm doubting it's the raphael code still seems semi-active (no releases in a while, but it still has 142k weekly downloads and it's @types/raphael was updated last year.

I'll keep you posted.

davfive commented 4 months ago

This issue has been fixed and is included in the v1.2.3 package release. Download or update it in Obsidian Settings under Community Plugins.

Taitava commented 4 months ago

Thank you @davfive ! πŸ™‚ I tested upgrading to 1.2.3, then restarted Obsidian and the problem got fixed! πŸŒžπŸ‘

david-trickybit commented 4 months ago

Thank you very much for taking the time to create this great plugin. πŸ˜€

davfive commented 4 months ago

@david-trickybit Thanks for the complementary note on my plug-in. Always nice to hear from a fan πŸ˜„