HappenApps / Quiver

Quiver documentation and issue tracker
2.26k stars 109 forks source link

Text Cell PDF Images Disappear #1251

Open ijoseph opened 5 years ago

ijoseph commented 5 years ago

Thanks again for a great product.

TL;DR: Towards the end of self-debugging, where, exactly, are PDF images stored in the file format (Quiver jsons?)

Long version:

I have a bizarre issue: when I copy PDF images into Text Cells, everything's fine for awhile:

image

Then, at some later point in time (anywhere between 15 minutes and a few weeks), the images seem to be missing (blue boxes with a question mark: image ).

This is maddening because it's hard to figure out exactly what caused the above.

More info: this is particularly occurring when I get PDF vector graphics from LatexIt. e.g.: image

I have not observed this behavior with PNGs.

ijoseph commented 5 years ago

Okay, I did some digging. Apparently inserted pdf images result in something like:

<img src=\"blob:file:///aa5d8482-fbc9-44cc-a307-c1c8112509ee\">

Whereas inserted png images are actually, apparently, converted into jpgs:

<img src=\"quiver-image-url/B0D4EE5522CE7C8065CC6736BC4A412F.jpg\" width=\"13\" height=\"50\">

Interestingly, I can find that file: B0D4EE5522CE7C8065CC6736BC4A412F.jpg in the Quiver.qvlibrary folder. However, I can not find anything matching the strange blob (aa5d8482-fbc9-44cc-a307-c1c8112509ee) above anywhere on my machine.

ijoseph commented 5 years ago

Update 2: okay, quitting and starting the app again seems sufficient to convert my PDF images into question-mark boxes. So the images must be stored in memory somewhere, somehow pointed to by blob:file:///….

ylian commented 5 years ago

Thanks for the detailed information. PNG, JPEG and most other image types are automatically saved to file, but PDF image is an edge case that I probably didn't handle.

The behaviour you have observed so far is the standard behaviour when you copy an image of any type into a text cell. The system basically keeps the image in memory temporarily, so restarting the app would resulting in the question mark. PNGs and JPEGs work because I have handled those image types and save the image from memory to file and update the image src.

I will look into a fix.

ijoseph commented 5 years ago

Thanks for your lightning response. Makes sense. That’s interesting. So when pasted in, Quiver renders any image by reading it directly from memory? Interesting. So the blobnotation is a memory address? Moot questions I guess because I cannot actually change the source code myself. I look forward to the fix.

Sent with GitHawk

ylian commented 5 years ago

@ijoseph Actually most work is done by the system. When you paste in an image, the system renders the image in the text cell, then gives it a fake URL. Quiver detects that an image has loaded, checks that it has a fake url, saves the image to disk, then updates the fake URL to a Quiver image url. The problem lies in the image detection part, as I need to make sure it's an image that's pasted in. As I said, I handled most image types, but pdf images are a special case.