-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
SingleFile in Safari does not save deferred images. #1022
Comments
Hi, that's strange. Unfortunately, I don't have a Mac so I cannot test SingleFile in Safari. Did you try to set |
No, that doesn't seem to do anything in Safari from my observation and it doesn't fix deferred image saving. Could you point me to the codepoints that govern this and the description on how it's supposed to work? I'll try to troubleshoot it more thoroughly myself then and submit a PR. |
Thank you for the feedback. I may be wrong but I have the impression that the problem is that SingleFile would not be able to override the |
We only inject |
Once built, this code is present in |
Sure, but deferred images load without it in Chrome, how come? If we don't want to load frames, is it ok to inject the script in the top frame? |
Are you sure you're not injecting this script in Chrome? The feature can't work if this script is not injected. Note that MV3 prevents you to inject scripts dynamically in the page (this is what SingleFile tries to do with MV2, see https://github.com/gildas-lormeau/SingleFile/blob/142eb26f961dd0a346834b58cb39931c2e42e216/src/lib/single-file/core/content/content-hooks-frames-extension-injection.js). You have to declare it in the manifest file, see https://github.com/gildas-lormeau/SingleFile-Lite/blob/main/manifest.json#L27. |
I am sure. Testing with MV2 extension for Chrome with this code: https://github.com/zotero/zotero-connectors/blob/safari-app-extension-maintenance/src/browserExt/background.js#L335-L340 Idk where this code comes from in
|
Either way, I injected that script into Safari and got:
for the override line, so the override works fine. Deferred images are still not saved though. Although the fact that it works in Chrome without this code raises more questions than it answers. |
The code in your previous comment is not directly related to deferred loading. It's a piece of code that tries to find the |
Regarding the logs, they look fine. Do you confirm that images were not loaded when you injected the script? |
Ok, I had the SingleFile extension enabled in Chrome, and if I disable it deferred image loading no longer works there either. Thanks for helping me through this confusion. So what do I need to inject into the main page beyond |
Yes, the images are not loaded. |
When you set |
Yep, that works and actually saves all deferred images, but we cannot use it with this UX in Safari. |
I understand, it's still a step forward though and it allows me to understand the issue. I think the simplest way for you to debug this problem is to put a |
I'm not sure if I will be able to troubleshoot this successfully today, and I am going away for a week, so if there's no more comments on my part -- sorry! Thanks for the help so far. Could you confirm whether we need to inject |
Ok, so it actually doesn't work in chrome even if I load |
I did some debugging in Chrome. You have to know that loading deferred images is painful, so SingleFile combines multiple techniques to do so. It looks like the code below is the one that makes the feature work on this page. This code overrides the You need to inject You need to inject I guess it works with SingleFile installed on your end because SingleFile injects the |
Ok, I'm getting back to this. I'm now testing on Chrome with SingleFile extension disabled, since this turned out to not be just the Safari issue. I've injected both {
"matches": ["http://*/*", "https://*/*"],
"run_at": "document_start",
"all_frames": true,
"js": [
"lib/SingleFile/single-file-hooks-frames.js",
"lib/SingleFile/single-file-frames.js"
]
} I see the scripts loaded via developer tools for the page, and I see If I step through Unfortunately, I cannot compare this to what happens when the SingleFile chrome extension is enabled, because that code is minified. Any other debugging steps that I may perform here? |
Following the discussion #1027, are you able to build a non-minified version of the code? |
Ok, I figured it out. The issue is NOT doing what you've been telling me to do, hah. I wasn't injecting _injectSingleFileHooks: function() {
const scriptElement = document.createElement("script");
scriptElement.src = getExtensionURL("lib/SingleFile/single-file-hooks-frames.js");
scriptElement.async = false;
document.body.appendChild(scriptElement);
scriptElement.remove();
} to correctly manually inject the file. Injecting via web extension APIs is wrong. Thanks a ton for help debugging this! |
Thank you for the feedback, I'm glad to hear you were able to find the cause of the issue :) |
Previously deferred image saving didn't work unless the SingleFile extension was also installed in the browser. See gildas-lormeau/SingleFile#1022 for detailed discussion
Hi. At Zotero we had two branches of Zotero Connector extension code, separate for Safari and other browsers, that we have now rebased back onto a single branch. Safari didn't use to support SingleFile before, but now it does. We run SingleFile completely standalone on the page and only provide a shimmed fetch function that ignores CORS. In Chrome SingleFile loads and saves deferred images on https://enviragallery.com/demo/lazy-loading-demo/, but it does not In Safari. I've tried increasing the deferred load timeout and enabling
loadDeferredImagesDispatchScrollEvent
, but Safari still doesn't load deferred images.The text was updated successfully, but these errors were encountered: