Comments (9)
Hi @adomasven,
I confirm I can reproduce the issue. I've done a debugging session. The issue is related to the _setFrameAttributes
function in the code of the connector, see https://github.com/zotero/zotero-connectors/blob/2325e9d2b20c9f80639063d71997868535935451/src/browserExt/zoteroFrame.js#L73C2-L83
The problem is that this function is called very often, even if the parameters don't change. I was able to circumvent the issue by replacing the implementation with the code below (I've added a few if
statements) to prevent attribute values from being updated if they don't change.
_setFrameAttributes(attributes, style) {
for (let key in attributes) {
if (this._frame[key] !== attributes[key]) {
this._frame[key] = attributes[key];
}
}
if (this._frame.getAttribute("id") !== attributes.id) {
this._frame.setAttribute("id", attributes.id);
}
for (let key in style) {
if (this._frame.style) {
this._frame.style[key] = style[key];
}
}
}
from singlefile.
It looks like the real issue is that the observer is never disconnected here https://github.com/zotero/zotero-connectors/blob/2325e9d2b20c9f80639063d71997868535935451/src/browserExt/zoteroFrame.js#L65-L70. I don't see the exit condition. The other problem is that the infinite loop due to the recursive call is too tight.
The DOMContentLoaded
bug is due to the src
attribute being constantly updated by _setFrameAttributes
.
from singlefile.
Confirmed, when uninstalled the Zotero plugin, SingleFile plugin works ok.
from singlefile.
@gildas-lormeau thanks for taking a look. I guess SingleFile is setting some attributes on all iframes that it's capturing which is causing this to run in the first place? The code you've discovered was recently added to prevent websites from accidentally "tampering" with the Zotero translation sandbox frame as that was causing it to take up empty space on some websites, but in my testing it wasn't causing things to run in an infinite loop. Either way, this should be easily enough resolved on our end.
from singlefile.
Zotero Connector will be fixed in the next release, pending Chrome extension store approval.
from singlefile.
@adomasven Thank you. I confirm that SingleFile adds an attribute containing an id on all frames in order to recognize them when processing the page.
Note that there is still a potential infinite loop here https://github.com/zotero/zotero-connectors/blob/b5cf8a0f326fc78ba4abcfa90b4cc9efd0a3ed57/src/browserExt/zoteroFrame.js#L66C4-L68 because observer.observe()
is always called after observer.disconnect()
. Ideally I think there should be a condition that would prevent observer.observe()
to be called indefinitely (e.g. when everything is done). Otherwise you could maybe use a timeout to allow the CPU to do some work between function calls to the listener (passed to the MutationObserver
constructor).
from singlefile.
Yes, that is intentional. The need to even have a mutation observer in the first place is because some websites change our iframes post page-load, and we can't know when, or whether they might decide to change them again (e.g. for navigation without page-load). I'm still not sure why SingleFile changing the id was causing an infinite loop. Is it repeatedly trying to change the ID too or something?
from singlefile.
It's true that when I think about it, I find it hard to understand why the listener was called following the modifications made by _setFrameAttributes
since it was disconnected. Maybe it's related to a special treatment of the src
attribute that would be asynchronous.
from singlefile.
You might still want to consider not saving extension frames in snapshots, but that should probably be a separate issue. Thanks for the help!
from singlefile.
Related Issues (20)
- Unable to edit page on mzh.moegirl.org.cn, blank in annotation editor with `Content Security Policy` errors (but open success, saved with smaller size) HOT 2
- Saving with Zip format (including SingleFileZ) fails to save some elements HOT 1
- The `white-space` attr will be removed after saving in Safari HOT 3
- Ability to run SingleFile within a Playwright context HOT 1
- Underlining of text HOT 1
- 保存网页后,本地html文件无法正常显示网页内容 HOT 3
- Re-save a folder as a self-extracting zip html file HOT 3
- Add support for `HTTPS-Only Mode` in Firefox HOT 12
- SingelFile does not work on Android Microsoft Edge at all HOT 4
- Some tab / button trigger by js not working HOT 3
- feature request: debug log traces to be monitored in console HOT 4
- I'm bit confused about help page HOT 1
- Why can't I click this button,i want debug the crx! HOT 1
- ebay capture doesn't save all images HOT 1
- Freeze on a Japanese website HOT 1
- 有些网址无法下载图片 HOT 1
- ScienceDirect snapshots are missing styles HOT 4
- Non-technical person here! Is it possible to save full websites with this? HOT 2
- Feature Request: support saving to s3 (or s3 compatible) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from singlefile.