Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Yomichan sometimes causes Google Docs to produce errors #608

Closed
Ceiyne opened this issue Jun 14, 2020 · 32 comments · Fixed by #619
Closed

Yomichan sometimes causes Google Docs to produce errors #608

Ceiyne opened this issue Jun 14, 2020 · 32 comments · Fixed by #619

Comments

@Ceiyne
Copy link

Ceiyne commented Jun 14, 2020

When I'm working in a Google Doc that has Japanese, Yomichan works fine most of the time. However, every now and again when I try to use Yomichan to look up a word, the Yomichan pop-up will appear but the Google Doc site will immediately produce an error saying "Unable to load file. Try to load it again or send an error report.".

When this happens, another error shows at the top of the page reading "Something went wrong. Reload" and the status of the connection to Google Docs changes to "Working offline". The only way to continue working with that file is to reload the document. I've attached a screenshot showing all of this.

yomichan gdocs

I was able to reproduce this behavior in several different Google Docs that I tried so it does not seem to be specific to a document. As I mentioned above, this doesn't happen on every look-up; if I'm looking up a lot of words, it'll usually happen every few minutes.

I went through a period recently where I didn't use Google Docs much, but I used to be a heavy user and I don't recall running into this before. So, I'd guess it's a relatively new problem that wasn't occurring a few months ago.

@toasted-nutbread
Copy link
Collaborator

toasted-nutbread commented Jun 14, 2020

  • What browser are you using?
  • When the issue does happen, does it only happen the first time the popup is opened? Or can it happen later on?
  • Does it happen on all documents (that you've tried)? You mention that it happens on more than one, but I'm curious if it's on every document.
  • Do you have any docs that you can reliably reproduce on?
  • Can you export and share your settings file from the settings page?
  • Do you have any other extensions installed?

@Ceiyne
Copy link
Author

Ceiyne commented Jun 14, 2020

What browser are you using? Google Chrome Version 83.0.4103.97 (Official Build) (64-bit)

When the issue does happen, does it only happen the first time the popup is opened? Or can it happen later on? It doesn't typically happen the first time the popup comes up; it seems kind of random as to when the issue occurs. Then, when I reload the Google Doc (either by hitting the Refresh button on the browser, or by hitting the Reload button in the Google error message in the screenshot I posted earlier) it'll work again for a short time until it happens on another random pop-up.

Does it happen on all documents (that you've tried)? You mention that it happens on more than one, but I'm curious if it's on every document. I can't definitively say if it happens on EVERY document, but it did happen on the several different ones I tried.

Do you have any docs that you can reliably reproduce on? Today it was happening a lot on one short document I have, so that might be a good one to work with. I could share it with you if you like, just send me a pm or post the email I should share it with. I'd prefer to share it read-only if that's OK. I wasn't editing the doc at all today (only using it to study, with Yomichan), and the problem still occurred. If you need it to be editable, that's OK, I'll just make a backup.

Can you export and share your settings file from the settings page? I don't think I've customized my installation much, but here are my exported settings.
yomichan-settings-2020-06-14-16-06-11.zip

Do you have any other extensions installed? Yes, here's a list of my active extensions:
Enable Right Click
Google Docs Offline
Google Hangouts
Google Keep Chrome Extension
Google Translate
LINE
Password Alert
Rakuten: Get Cash Back For Shopping
uBlock Origin
Yomichan

@toasted-nutbread
Copy link
Collaborator

If you are able to export the document to a .docx (File > Download > Microsoft Word (.docx)), I think I can just import that onto my testing account. Feel free to remove anything from it before sharing; my limited test case I've used in GDocs before is currently not exhibiting the issue.

I have a few guesses as to where the issue might be coming from; I've already identified a place where GDocs causes Yomichan to throw an error, so I'll be looking into that.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 14, 2020

Thanks. Here's the docx... I didn't change anything in it, so it should hopefully match what I'm looking at exactly.
yomichan gdocs.docx

@toasted-nutbread
Copy link
Collaborator

Forgot to ask earlier: if you click the "send an error report" text, does it show any information? Still doing some testing and I haven't been able to reproduce the issue yet.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 14, 2020

This is the pop-up that appears if I click "send an error report".

image

The middle part is an automatically-generated screenshot of the gdocs tab.

I also have some new information for you. I was playing around with different things to see if I could find any way of more reliably reproducing the issue, and I found something where I can make it happen 100% of the time.

  1. Hover over Japanese text and move the mouse cursor slightly while pressing the middle mouse button
    Note: I have the "Middle mouse button scans" option turned on

  2. The mouse pointer turns into the auto-scroll symbol (shown in the image below) and the issue immediately occurs (the Yomichan pop-up appears along with the gdocs error message, as described in my first post)
    image
    Note: If you do not move the mouse while pressing the middle mouse button in step 1, Yomichan does not pop-up, and the issue also does not happen.

FYI, when I posted the issue earlier, I was only using Yomichan's default shift key scanning and still experienced the issue -- it just wasn't as consistent as with the middle mouse button scanning.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 14, 2020

I also meant to mention this above, in case it helps. I already said that if I press the middle mouse button and do not move the mouse, Yomichan does not scan and the problem does not occur. However, my next scan (even a shift-key scan) will then always trigger the problem.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 20, 2020

I don't know if this is helpful, but I've noticed that if I leave a gdocs window open for a long time, when I eventually go back to it, I usually get the issue on the first lookup I try to do. I don't know if this is a time-based thing, or if it's something else (like losing & restoring network, or sleeping and resuming my PC).

@toasted-nutbread
Copy link
Collaborator

I've tried to reproduce following the different steps you've listed, but so far I have not been able to reproduce the problem. Yomichan has a very small set of operations which are able to be detected by the underlying website, which currently includes:

  • Adding the popup frame to the page.
  • Adding some CSS rules to the page.
  • Selecting the text on the page.
  • In a few instances, sending messages to the underlying page. (I am working on removing these, but it doesn't seem like they would be causing the issue based on when these message are sent.)
  • Modifying some styles and then reverting them during text scanning if the option "Deep DOM scan" is enabled. (This is disabled by default)

You could try disabling the "Select matched text" and "Deep DOM scan" options and see if you still get the problem. Otherwise, it's not clear how Yomichan is causing the issue. One last thing you could check is the dev console after the error occurs. Press F12, open the Console tab, and see if there is anything listed in there.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 20, 2020

Deep DOM Scan was already off, and disabling Select Matched Text didn't fix the issue. (I made sure to reload the gdocs page after changing the option, in case that was necessary.)

I tried to produce the error with Yomichan turned off, but nothing happened when I performed the same steps that normally reproduce it 100% of the time (click middle mouse button, then press left shift while moving the mouse).

I tried to rule out Yomichan by using the Rikaikun browser extension instead. I disabled Yomichan prior to enabling Rikaikun. However, I was unable to reproduce the problem when using Rikaikun. I tested with several different options within Rikaikun such as requiring a key press to generate the pop-up, or not requiring a key. I also tried sleeping and resuming my computer, since that seemed to cause the problem to happen more frequently, but the issue still did not occur.

I don't usually use gdocs from my Chromebook, but I tried today and could not reproduce the issue there. The PC where I am experiencing the issue is Windows 10 Home, 10.0.19041 (not sure if it's apparent from the version number or not, but I've already applied the latest "big" update from the past month or so).

I did as you suggested and looked at the dev console when the error occurs. Here are a few screenshots of what appears. I checked a few times and the errors were the same each time. Let me know if there's anything useful here, or if anything else from this window would be helpful.

image

image

image

@Ceiyne
Copy link
Author

Ceiyne commented Jun 20, 2020

I just realized I had only looked at the console after I had reproduced the issue, so I didn't know if any of the errors were already there before the issue occurred. I just now checked and the first two errors in my screenshot (the deprecation and the TypeError) are there on a fresh reload of gdocs, before the issue occurs. The third one (the "JJa" error) only appears when the error occurs.

@toasted-nutbread
Copy link
Collaborator

toasted-nutbread commented Jun 20, 2020

The one about 'Cannot destructure property ...' is an error Yomichan is having, but it's passive for the most part and doesn't break anything. This has since been fixed. The 'JJa' one is lkely the offending error. If you could get that error again and expand the details (click the arrows/...) on the So, stack, and whatnot (ignore __proto__) and capture that, that could be helpful.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 21, 2020

image

The So DOMException line ran off the screen. It contains the following:

DOMException: Blocked a frame with origin "https://docs.google.com" from accessing a cross-origin frame.
    at cu (https://docs.google.com/static/document/client/js/1713288375-client_js_prod_kix_core.js:248:430)
    at Qjj.L (https://docs.google.com/static/document/client/js/3610900267-client_js_prod_kix_ita.js:302:259)
    at b (https://docs.google.com/static/document/client/js/1713288375-client_js_prod_kix_core.js:210:104)

The stack at the bottom contains the same thing as the DOMException.

@toasted-nutbread
Copy link
Collaborator

So the error is kind of reproducible by typing cu(document.querySelector('.yomichan-float')) into console, but it's unclear why GDocs is accessing the frame, particularly when it's not happening for me. I'll continue to look into this, but this feels like a behaviour that GDocs should not be doing.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 21, 2020

Do you have any ideas on stuff I could try to do to avoid the error? For example, Chrome options, other extensions to disable, etc.? (Although as far as I know, my PC and Chromebook have the same Chrome settings and extensions, and I haven't been able to reproduce on my Chromebook.)

Or if there's some kind of further debugging I could do to help figure out why gdocs is (incorrectly) accessing the yomichan frame, please let me know.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 21, 2020

I tried a couple more things, but they didn't fix the issue:

  • disabled all extensions other than Yomichan
  • disabled dictionaries, leaving just one active at a time
  • disabled middle mouse button scanning

I also tested other types of Google documents:

  1. Sheets gives a similar error. Yomichan doesn't seem to work on text within spreadsheet cells, but I can reproduce the error 100% of the time by using Yomichan normally to scan Japanese text in the formula bar (i.e., I don't need to use the middle mouse button - I just use shfit-to-scan like normal and the issue occurs).

image

DOMException contents:

DOMException: Blocked a frame with origin "https://docs.google.com" from accessing a cross-origin frame.
    at Sn (https://docs.google.com/static/spreadsheets2/client/js/272480816-waffle_js_prod_core.js:516:430)
    at aVe.J (https://docs.google.com/static/spreadsheets2/client/js/3790144471-waffle_js_prod_inputtools.js:348:352)
    at b (https://docs.google.com/static/spreadsheets2/client/js/272480816-waffle_js_prod_core.js:611:103)

2. Slides produces a similar error. Yomichan doesn't seem to work on content within a slide, but I was able to trigger the issue inside the "Word art" popup (Insert menu -> Word art -> Type in pop-up). As with Sheets, I didn't have to do anything special to make the issue occur here, and it occurs 100% of the time.

image

DOMException contents:

DOMException: Blocked a frame with origin "https://docs.google.com" from accessing a cross-origin frame.
    at Rd (https://docs.google.com/static/presentation/client/js/3065501838-editor_js_prod_core.js:99:430)
    at qJf.O (https://docs.google.com/static/presentation/client/js/2152801621-editor_js_prod_ita.js:321:352)
    at b (https://docs.google.com/static/presentation/client/js/3065501838-editor_js_prod_core.js:254:103)
  1. Forms does NOT seem to have the issue. I was unable to reproduce it, even with the middle mouse button method. (Note: Yomichan does not seem to work in the form designer, but does work if you "preview" a form you've created, and that's where I tested it.)

  2. I also tested the docs.google.com "document browser" screen, which does NOT seem to have the issue. Some of my documents have Japanese in the title and I was unable to reproduce the issue, even with the middle mouse button method.

@toasted-nutbread
Copy link
Collaborator

Thanks for the detailed information. Even trying it on the sheets/slides pages, I get no issues. I do have one more thing that you can try, but it's not a good long term solution. The change is that recently we changed the way that the Yomichan popup is assigned its content URL, and maybe GDocs will behave if Yomichan uses the old method.

Here is a packaged extension, created from #618.
yomichan-with-unsecure-frame-url.zip

What you will have to do to use this is to:

  1. Extract the contents of the .zip to a folder
  2. Open the chrome://extensions/ page
  3. Enable "Developer mode" on the right
  4. Click the "Load unpacked" button on the left
  5. Select the folder that you extracted to
  6. Temporarily disable your main Yomichan extension and set up this one instead (dictionaries, settings, etc.)
  7. On the settings page, enable "Show advanced options" and then enable "Use unsecure popup frame URL"
  8. Test to see if you still get the same issue

This is not a great long-term solution, as it allows fingerprinting of Yomichan because the extension URL is exposed. I will be working on trying other solutions as well.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 21, 2020

I just finished testing the developer version you shared with me. When the unsecure frame option is on, I could not reproduce the issue, so I think you nailed it. I didn't test with every Google document type, but I did try both Docs and Sheets. In the situations where I could consistently reproduce the issue before, the issue no longer occurs at all.

I also tried the developer version with the unsecure frame option turned off, and the problem happens as usual.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 21, 2020

By the way, it's not related to this issue, but when I was re-downloading the dictionary files from the Yomichan page, I noticed something that seemed wrong.

https://foosoft.net/projects/yomichan/
image

The circled links both go to the same site, which is a page for ENAMDICT/JMnedict, and not JMDict.

@toasted-nutbread
Copy link
Collaborator

toasted-nutbread commented Jun 21, 2020

Okay, so I think GDocs is somehow erroneously detecting the frame as something it has ownership over when there is no URL assigned directly to the object. Still unclear why it is not able to be reproduced, but oh well.

If you're comfortable using the dev release I made, you can use that for now. I'll work on fixing some things up, adding that option to the full release, and work on adding a better solution that maintains security.

By the way, it's not related to this issue, but when I was re-downloading the dictionary files from the Yomichan page, I noticed something that seemed wrong.

Fixed in #619.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 21, 2020

Are there any downsides to me using the dev release for now? Like, does it somehow leave me insecure as I'm browsing the web with it active? (Other than the issue with potential browser fingerprinting, which I understand.)

Also, can I turn off "Developer Mode" in the Extensions page? I'm not sure if that was only required for installation, or if I need to keep it on for the dev release to continue to work.

Thanks for all your help with this.

@toasted-nutbread
Copy link
Collaborator

Are there any downsides to me using the dev release for now?

  • The extension will not auto-update in this mode. I'll be working towards a new release which contains some of these fixes, but you will have to manually switch back to the main branch to continue getting feature updates. I'll try to comment on this thread when that happens; might be a week or two.
  • There are some additional changes in the dev release which aren't in the latest 20.5.22.1 release. So if you notice any issues, please report them as well. I will be doing some testing myself after I get the remaining features in for the next release.
  • If you are using standard Chrome, you may get a warning about disabling "untrusted" extensions (or something similar) on startup, since you have manually loaded Yomichan. You can ignore this warning for now.

Like, does it somehow leave me insecure as I'm browsing the web with it active?

Should be the same security as the real release. This is how extension developers test extensions before deploying them to the store.

Also, can I turn off "Developer Mode" in the Extensions page?

You can turn it off if you like. All it does is show some more options on that page (like the "Load unpacked" button, and such).

@toasted-nutbread
Copy link
Collaborator

I have done some work on a better solution for the issue you have been experiencing, which should increase the security and integrity of the popup frame overall. The popup frame is now enclosed inside of a container which the scripts on the underlying page should not be able to be see inside. This means that GDocs shouldn't try to use the popup frame since it won't know it's there.

Here is a new release which is created off of #623. Try this release with both options "Use secure popup frame URL" and "Use shadow DOM container for popup" (new) checked (which is the default). Hopefully this should fix your issue without having to disable any security features.
yomichan-with-shadow-dom.zip

Note: the old option "Use unsecure popup frame URL" has been replaced with with the new "Use secure popup frame URL", which has the opposite value.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 23, 2020

The new version looks great. I have both of those options on, and I cannot reproduce the issue.

@FooSoft
Copy link
Owner

FooSoft commented Jun 23, 2020

@toasted-nutbread this seems like a pretty solid fix that should be in a release; is there anything else you want to flight in a test build, or are things in a good state?

@toasted-nutbread
Copy link
Collaborator

Give me a day or two to do some testing with the changes made so far; if there are no issues, I'll let you know that it's good to go. I don't think I need to add any more big features/changes for this release; only small fixes and whatnot.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 24, 2020

I wanted to let you know that the 2 dev builds just disappeared from my computer. I did a couple of things before this happened:

1. Changed my Windows computer name
2. Rebooted my PC

If it's just a known thing that dev extensions get wiped on a computer name change or something, that's fine. I just wanted to let you know because I wasn't expecting it to happen.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 24, 2020

I just realized something else I did. Right before I changed my computer name, I was cleaning up and I deleted the directories I had installed the dev builds from. I was thinking that Chrome had taken those files and installed them someplace and the directories were no longer needed. Now, I'm guessing that it keeps using the files in the original directories, so when I deleted them, the extensions went away.

If you could please confirm that that's how it works, I will try to pretend like this never happened. :)

@Ceiyne
Copy link
Author

Ceiyne commented Jun 24, 2020

Bingo. I restored the folders from the Recycle Bin, restarted Chrome, and they were back. Sorry for the false alarm!

@toasted-nutbread
Copy link
Collaborator

@FooSoft I've done some testing and haven't noticed any issues so far. It should be good to go.

Changelog

@toasted-nutbread
Copy link
Collaborator

FYI @Ceiyne, the dev version has been updated with the latest fixes, and the standard version typically gets updated ~1 week after.

@Ceiyne
Copy link
Author

Ceiyne commented Jun 28, 2020

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants