scambier / obsidian-text-extractor

A (companion) plugin to facilitate the extraction of text from images (OCR) and PDFs.
GNU General Public License v3.0
346 stars 19 forks source link

[BUG] Obsidian Helper (Renderer).app crash on macOS 13.2 #11

Open phatblat opened 1 year ago

phatblat commented 1 year ago

Problem description

This week I upgraded my Mac Studio from macOS 13.1 to 13.2 and immediately my synced vault started being unusable. Non-synced vaults are functioning normally.

Behavior

When I open up my primary vault synced through Obsidian’s sync service, I can see my last note and interact with it for a few seconds. Then, suddenly the entire window goes blank. I can resize it but can’t move it around - there’s no top bar but there are the 3 macOS colored circle buttons in the upper left corner. Closing and reopening the vault gives me another few seconds to interact with the note before the window goes blank again.

I copied the vault to a new location (so that it's not being synced) and opening the new copy exhibits the same behavior.

Screenshot 2023-01-26 at 1 40 45 PM

In the system console I found evidence that the Obsidian Helper (Renderer).app is crashing. The main thread stack trace doesn't appear to be related to your plugin. I didn't include all the other threads since the crash report is huge so let me know if there are any specific worker thread details that would help.

Disabling the plugin prevents this crash. (See workaround below)

Crash report

Date/Time:             2023-01-26 12:38:52.6840 -0700
OS Version:            macOS 13.2 (22D49)
Report Version:        12
Anonymous UUID:        2D758FDE-B5F2-8D4E-269B-A203E6EAED78

Sleep/Wake UUID:       DF7620BE-1124-494D-A6D9-E1D32AE4C045

Time Awake Since Boot: 140000 seconds
Time Since Wake:       99849 seconds

System Integrity Protection: enabled

Crashed Thread:        68  DedicatedWorker thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x000000011742b574

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [68377]

Thread 0:: CrRendererMain Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x19b596050 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x19b5a811c mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x19b59ec24 mach_msg_overwrite + 452
3   libsystem_kernel.dylib                 0x19b5963cc mach_msg + 24
4   CoreFoundation                         0x19b6b5bb0 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x19b6b449c __CFRunLoopRun + 1232
6   CoreFoundation                         0x19b6b3878 CFRunLoopRunSpecific + 612
7   Foundation                             0x19c5beab8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8   Electron Framework                     0x117498104 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 15855736
9   Electron Framework                     0x117496e64 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 15850968
10  Electron Framework                     0x11745eeec v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 15621728
11  Electron Framework                     0x11742ea80 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 15423988
12  Electron Framework                     0x11a3d9a98 node::CommonEnvironmentSetup::event_loop() const + 15963828
13  Electron Framework                     0x114f57d08 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 14156
14  Electron Framework                     0x114f58624 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 16488
15  Electron Framework                     0x114f571b8 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 11260
16  Electron Framework                     0x114f57684 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 12488
17  Electron Framework                     0x114ce1688 ElectronMain + 128
18  Obsidian Helper (Renderer)             0x104b2499c 0x104b24000 + 2460
19  dyld                                   0x19b2abe50 start + 2544
Looks like some crash in Electron

https://forum.obsidian.md/t/obsidian-crashes-on-mac-after-update-on-every-few-seconds/52951/15?u=phatblat

Workaround

I was able to resolve the issue by manually deleting the Text Extractor cache located at .obsidian/plugins/text-extractor/cache in the vault folder and then reopening the vault. After some time the vault will stop rendering again, but purging the cache allowed me to disable the plugin and use Obsidian normally.

With the plugin re-enabled and the cache freshly purged, I can watch it generate lots of .json under the cache subfolder. It looks like the plugin gets through a little over half of my images before it stops and the renderer crashes (561 .json files in .obsidian/plugins/text-extractor/cache/sc).

The last successfully written file is 2022-04-18 Monday Ditto Worklog-Screen Shot 2022-04-18 at 3.31.52 PM.png-5629be631531de426a2eccec772c94bd.json

{"path":".obsidian/plugins/text-extractor/cache/sc/2022-04-18 Monday Ditto Worklog-Screen Shot 2022-04-18 at 3.31.52 PM.png-5629be631531de426a2eccec772c94bd.json","text":"€3 Application could not be uploaded to the device.","libVersion":"0.0.0","langs":"eng","hash":"","size":0}
Screen Shot 2022-04-18 at 3 31 52 PM

Screenshot 2023-01-26 at 1 48 03 PM

⚠️ Problem Image?

It looks to me like it's been processing images in reverse chronological order, so this one would have been next.

Screenshot 2023-01-26 at 1 49 12 PM

Screen Shot 2022-04-18 at 2 38 26 PM

Is there any way to see which image the plugin was working on when it crashed?

Environment

phatblat commented 1 year ago

Removing the visual studio error message image out of my vault allows the text extractor plugin to continue processing other images without crashing. I ended up with 788 .json files in the cache/sc folder. Several other cache subfolders got created and then it appeared that the text extraction finished because the activity in the cache folder stopped.

Screenshot 2023-01-26 at 2 01 16 PM

I then moved the problem image back into my vault at the original subfolder location. I expected Obsidian to crash but it didn't and appears to have processed the image successfully.

{"path":".obsidian/plugins/text-extractor/cache/sc/2022-04-18 Monday Ditto Worklog-Screen Shot 2022-04-18 at 2.38.26 PM.png-3da7dbd812c24bdebbf7cd4b008a21c1.json","text":"Error while trying to load the project '/Users/phatblat/dev/ ditto/ditto/dotnet/Xamarin/ Ditto.NuGet/Ditto.NuGet.nuproj': Importing the file \"[Users/ phatblat/dev/ditto/ditto/dotnet/ Xamarin/Ditto.NuGet/ Ditto.NuGet.nuget.props\" into the file \"/Library/Frameworks/ Mono.framework/Versions/ 6.12.0/lib/mono/xbuild/Microsoft/ NuGet/Microsoft.NuGet.props\" results in a circular dependency.","libVersion":"0.0.0","langs":"eng","hash":"","size":0}

Additionally, I am able to find this image using Omnisearch after it is indexed:

Screenshot 2023-01-26 at 2 07 54 PM

Screenshot 2023-01-26 at 2 06 41 PM

Now I'm confused why it crashed in the first place.

scambier commented 1 year ago

The macOS update was probably a coincidence, but I can't explain why this particular file caused a crash (and then did not). At Obsidian startup, Text Extractor will output a log saying "X workers available", could you tell me how many workers does it have please?

Your Obsidian installer version is also quite out of date I think, it's worth it to update it. You need to re-download Obsidian for that, it can't self-update.

phatblat commented 1 year ago

Updated the Obsidian macOS host app using Homebrew.

brew info obsidian
==> obsidian: 1.1.16 (auto_updates)
https://obsidian.md/
/opt/homebrew/Caskroom/obsidian/1.0.0 (122B)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/obsidian.rb
==> Name
Obsidian
==> Description
Knowledge base that works on top of a local folder of plain text Markdown files
==> Artifacts
Obsidian.app (App)
==> Analytics
install: 24 (30 days), 2,993 (90 days), 31,075 (365 days)

brew reinstall obsidian
==> Downloading https://github.com/obsidianmd/obsidian-releases/releases/download/v1.1.16/Obsidian-1.1.16-universal.dmg
...

brew info obsidian
==> obsidian: 1.1.16 (auto_updates)
https://obsidian.md/
/opt/homebrew/Caskroom/obsidian/1.1.16 (122B)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/obsidian.rb
==> Name
Obsidian
==> Description
Knowledge base that works on top of a local folder of plain text Markdown files
==> Artifacts
Obsidian.app (App)

Startup Logs

Looks like it's starting up 14 workers

Text Extractor - Number of available workers: 12 for PDFs, 2 for OCR