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

Disable WebView's cache #747

Merged
merged 1 commit into from Feb 6, 2017

Conversation

niklasberglund
Copy link
Collaborator

Fix #746 image cache issue. Using private API [WebCache setDisabled:YES] to disabled the cache of WebView. The cache should be disabled, right? Or is there any reason for keeping it enabled?

Feel so so about using private API. Kinda okay since MacDown isn't in the app store. A long term solution is probably what @uranusjr suggested in the #746 comments - migrating to using WKWebView instead of WebView. That might solve this issue as well.

With this fix image will be reloaded when reloading preview or removing and re-adding the image markdown.

Side note: Another small nice feature might be to trigger a reload of the preview when MacDown enters foreground? Then changes made to images in another application would automatically be updated when returning to MacDown.

@niklasberglund
Copy link
Collaborator Author

Created PR #748 with commit implementing what I mentioned in the side note above

@uranusjr
Copy link
Member

uranusjr commented Feb 6, 2017

Oooooh this is nice. How did you even find this API?

@uranusjr uranusjr merged commit 3752c6f into MacDownApp:master Feb 6, 2017
@niklasberglund
Copy link
Collaborator Author

@uranusjr googling. Lots of googling 😊 I found it mentioned somewhere.
I don't have the habit of using it, but I think private APIs are usually discovered by using otool or a similar tool on binaries.

@FranklinYu
Copy link
Member

Man, why would this API be private at all?!

@niklasberglund
Copy link
Collaborator Author

niklasberglund commented Feb 8, 2017

@FranklinYu there are public APIs for managing the cache of WebView. They just don't work 😄 Really weird. This is a long standing issue with the web view component. I assume 🙏 it has been solved with the newer WKWebView component.

@FranklinYu
Copy link
Member

If that's the case, this gets convoluted only because we try to support Mountain Lion and Mavericks?

@niklasberglund niklasberglund deleted the image-cache-issue branch February 9, 2017 03:39
@niklasberglund
Copy link
Collaborator Author

Yes. WKWebView is supported starting from 10.10. If 10.8 is dropped(#738) then there's still 10.9 which doesn't support WKWebView.

buzzert added a commit to buzzert/macdown that referenced this pull request Jan 12, 2022
For issue MacDownApp#747, a change was introduced that uses private API to disable
caching on the preview pane's web view. This was ostensibly to make it
so that if images referenced in the markdown document are changed on
disk, their changes are reflected in the preview pane.

Unfortunately, perhaps due to some underlying changes to WebKit/WebView,
disabling caching will also disable caching for all sorts of other
things like stylesheets and the base html document loaded from disk.
This results in a momentary flash of empty content if one is typing
quickly.

Reverting the changes for MacDownApp#747 resolves the flashing issue, but does
regress the issue regarding images being persistently cached.

However, the flashing issue appears to be bothering more people than the
image issue, so I believe it would be appropriate to temporarily regress
the image caching bug to resolve the flashing bug. Supposedly, a plan
exists to migrate to WKWebView, which would hopefully resolve both of
these issues simultaneously.
mdznr pushed a commit to mdznr/macdown that referenced this pull request Oct 22, 2022
For issue MacDownApp#747, a change was introduced that uses private API to disable
caching on the preview pane's web view. This was ostensibly to make it
so that if images referenced in the markdown document are changed on
disk, their changes are reflected in the preview pane.

Unfortunately, perhaps due to some underlying changes to WebKit/WebView,
disabling caching will also disable caching for all sorts of other
things like stylesheets and the base html document loaded from disk.
This results in a momentary flash of empty content if one is typing
quickly.

Reverting the changes for MacDownApp#747 resolves the flashing issue, but does
regress the issue regarding images being persistently cached.

However, the flashing issue appears to be bothering more people than the
image issue, so I believe it would be appropriate to temporarily regress
the image caching bug to resolve the flashing bug. Supposedly, a plan
exists to migrate to WKWebView, which would hopefully resolve both of
these issues simultaneously.
shankerwangmiao pushed a commit to shankerwangmiao/macdown that referenced this pull request Nov 12, 2022
For issue MacDownApp#747, a change was introduced that uses private API to disable
caching on the preview pane's web view. This was ostensibly to make it
so that if images referenced in the markdown document are changed on
disk, their changes are reflected in the preview pane.

Unfortunately, perhaps due to some underlying changes to WebKit/WebView,
disabling caching will also disable caching for all sorts of other
things like stylesheets and the base html document loaded from disk.
This results in a momentary flash of empty content if one is typing
quickly.

Reverting the changes for MacDownApp#747 resolves the flashing issue, but does
regress the issue regarding images being persistently cached.

However, the flashing issue appears to be bothering more people than the
image issue, so I believe it would be appropriate to temporarily regress
the image caching bug to resolve the flashing bug. Supposedly, a plan
exists to migrate to WKWebView, which would hopefully resolve both of
these issues simultaneously.
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

Successfully merging this pull request may close these issues.

Modified image not updated in preview
3 participants