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

TypeError: window.getSelection() is null in Firefox, causing sporadic issues #2273

Open
bashenk opened this issue Nov 22, 2022 · 1 comment

Comments

@bashenk
Copy link

bashenk commented Nov 22, 2022

Description

Consistent error, which sporadically causes significant issues in some pages in Firefox.
The error, as shown in the stack trace below, is TypeError: window.getSelection() is null

Note: I use Firefox Portable. However, I have no reason to believe at this point it is exclusive to the portable version.

Steps to reproduce

Open Firefox with Yomichan installed and open a tab to YouTube. Error will be in the console while loading the page.
Sometimes, when browsing to a video, it will completely prevent the video from starting until I disable this add-on. However, it does appear that once a video has loaded once in that session, subsequent videos will usually load even with this enabled. Hence, I have primarily encountered it when loading a video in a new private window.

Note that the error is not exclusive to YouTube, but I haven't specifically noticed how it affects other pages.

Stack trace

15:03:13.384 Yomichan 22.10.23.0 has encountered a problem.
Originating URL: about:blank
TypeError: window.getSelection() is null
setEnabled@moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/language/text-scanner.js:147:63
prepare@moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/language/text-scanner.js:121:14
prepare@moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/app/frontend.js:141:27
async*@moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/app/content-script-main.js:51:24
async*@moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/app/content-script-main.js:57:3

Issues can be reported at https://github.com/FooSoft/yomichan/issues core.js:732:35
    log moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/core.js:732
    error moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/core.js:754
    <anonymous> moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/app/content-script-main.js:55
    <anonymous> moz-extension://967dad89-e02d-41c4-9d90-7f188875dbb2/js/app/content-script-main.js:57

Possible cause/solution

Looking into window.getSelection() online seems to show that this is something that has affected Firefox for a very long time.
See this stackoverflow answer for further information:
https://stackoverflow.com/questions/20419515/window-getselection-of-textarea-not-working-in-firefox/20427804#20427804

Browser version

Firefox (64-bit) 106.0.5 and 107.0
And some earlier versions, before I decided to submit the bug report

Yomichan version

22.10.23.0 and likely some earlier versions

@TomPlum
Copy link

TomPlum commented Nov 23, 2022

I'm getting the same in Firefox and Chrome. Can't add cards to Anki, the button is greyed out and the console consistently shows the same error.

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

No branches or pull requests

2 participants