odoo / odoo

Odoo. Open Source Apps To Grow Your Business.
https://www.odoo.com
Other
38.63k stars 25.04k forks source link

[9.0] Failed to read the 'rules' property from 'CSSStyleSheet': #22517

Closed thomas15v closed 6 years ago

thomas15v commented 6 years ago

Impacted versions:

Steps to reproduce:

Video/Screenshot link (optional): image Screenshot from Gyazo

Yenthe666 commented 6 years ago

Hi @thomas15v,

Thanks a lot for your report. I've just tried this on the latest Odoo 9 (community) on Chrome and Firefox and it seems to work fine. Can you reproduce it on an official test instance (runbot.odoo.com) Do you have custom plugins added that modify CSS? Is your Odoo on the latest source code? Which version of Chrome are you using?

Regards, Yenthe

thomas15v commented 6 years ago

Forgot to mention that you need Chrome 64.0.3282.119 akka the latest version. Updated rolled in yesterday. Screenshot is from runbot.

Yenthe666 commented 6 years ago

Seems to work fine at my end. CC @ged-odoo as it is JS related.

thomas15v commented 6 years ago

Just tried with a fresh google chrome without any addons, same problem. I actually knew about this bug a while longer since I use chrome beta, but I didn't thought it would make it to the stable version.

Also we have this error on every odoo version, when right clicking a link (menuitem in community). Screenshot from Gyazo. I am not sure if they are related, but since it is happening with the same chrome version I think it might.

cmarrero commented 6 years ago

I can confirm the error with chrome 64

jakubhruby commented 6 years ago

metoo

on ArchLinux Firefox has not this problem

Yenthe666 commented 6 years ago

Yep, got it too now: image

ged-odoo commented 6 years ago

this is interesting. Yesterday, I had the crash (the one with the addeventlistener), in chrome 63. I thought we broke odoo, i tested on different versions. Then, I thought it could be related to extensions, so I disabled all my chrome extensions (just 4 or 5, not a big user of extensions), and restarted chrome. The problem disappeared.

ged-odoo commented 6 years ago

difficult to say, but my first guess is that the addeventlistener crash is related to chrome, not odoo's code. However, I don't know for the other crash with cssstylesheet.

ged-odoo commented 6 years ago

does it happen for version 10/11?

thomas15v commented 6 years ago
traviswaelbro commented 6 years ago

Also having this problem on version 9. Confirmed to happen when trying to "Send by Email" on Invoices with Chrome v64.0.3282.119.

aek commented 6 years ago

Seems that basically, the issue is related to an empty CSS stylesheet introduced dynamically here: https://github.com/odoo/odoo/blob/9.0/addons/mail/static/src/js/announcement.js#L16 in the format of:

_ab_location: function(dbuuid) {
    return _.str.sprintf('https://services.openerp.com/openerp-enterprise/ab/css/%s.css', dbuuid);
},

That js file does not introduce any useful feature for clients and it's returning an empty response - at least for non-enterprise database uuid - it's causing this issue with the chrome 64. That js file or the code it contains was removed for new versions of Odoo. Mostly that's the reason that you couldn't reproduce it in new versions

Still could be helpful to better catch the error here: https://github.com/odoo/odoo/blob/9.0/addons/web_editor/static/src/js/transcoder.js#L16 to avoid this situation in the future

The most simple solution could be that Odoo S.A fix the CSS response of that file to at least one CSS Rule for that Ghost file Another one could be simple extend (or manually find) the view record for mail assets to remove the line: <script type="text/javascript" src="/mail/static/src/js/announcement.js"/> Like this:

<template id="mail_assets_backend" name="mail assets" inherit_id="mail.assets_backend">
    <xpath expr="//script[@src='/mail/static/src/js/announcement.js']" position="replace"/>
</template>

I have tested that template extension to remove the inclusion of the announcement.js file and it seems like solving the issue at least in the detected scenario of the empty CSS file.

Talking about the solution for web_editor/static/src/js/transcoder.js you will need to remove the load of the original file and replace it with your fixed version. But I think that it won't be necessary if the previous patch fix completely the situation

Best Regards

KottmannM commented 6 years ago

I have the same problem with odoo 9 enterprise.

wim-a commented 6 years ago

We also have the same problem with Odoo 9 Enterprise.

jithinkr12345 commented 6 years ago

Do we got any fix for this issue??? @Yenthe666

MouTio commented 6 years ago

It appears that the property "rules" is missing in the CSS resource and in Firefox is treated as a warning, but in Chrome is treated as an exception.

If you show the console of both browsers, you will see the messages. Try to enter to "Preferences" or to edit a random user.

This is the error shown by Firefox console in runbot: Can't read the css rules of: https://services.openerp.com/openerp-enterprise/ab/css/ddf53f40-028e-11e8-ab9c-a4bf011da6d8.css

MouTio commented 6 years ago

Okay, the solution is to change the code of transcoder.js located in web_editor/static/src/js:

The property "rules" is not well checked.

This line is wrong (around line number 16): if (sheets[i].rules) {

It has to be changed to this: if (sheets[i].hasOwnProperty('rules')) {

and the code will work fine in Chrome browser too.

I have created a PR.

Please, verify it, @Yenthe666 @ged-odoo

wim-a commented 6 years ago

I installed this fix. Works fine. Thanks a lot.

ThomasBinsfeld commented 6 years ago

Same issue. @MouTio fix seems to work fine :+1:

Yenthe666 commented 6 years ago

My co-worker created an official ticket for this with the number 813371

MouTio commented 6 years ago

@Yenthe666 What is an 'official ticket'? Is it the same as PR? I created my first PR to fix this bug:

https://github.com/odoo/odoo/pull/22603

Yenthe666 commented 6 years ago

@MouTio an official bug report is one reported through odoo.com/help with your enterprise license key. It means that the issue moves up the list and gets a high(er) rating.

remi-filament commented 6 years ago

I have the same issue on Odoo CE v10 - I have created PR #22679 to address this issue on v10

treviser commented 6 years ago

I have the same issue on Odoo CE v11

Yenthe666 commented 6 years ago

@ged-odoo any feedback? A dozen or so people are reporting this already.

ronniescs commented 6 years ago

I have the same issue on Odoo Ent v10

mevivek4u commented 6 years ago

I had the same issue with odoo9, but solved using the code given by @MouTio

traviswaelbro commented 6 years ago

Agreed. The fix given by @MouTio resolves the problem on my end as well.

ged-odoo commented 6 years ago

issue fixed in 9.0 and 10.0. Thank you everyone for your contribution/research/time/comments.

treviser commented 6 years ago

@ged-odoo Do you plan to fix it for 11.0 too, can I provide some help?

aryeharmon commented 6 years ago

still an issue Version 64.0.3282.119 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit)

treviser commented 6 years ago

I'm using the same Google version as @aryeharmon on Ubuntu 17.10.

thomas15v commented 6 years ago

How do you make the issue happen in 11?

jakubhruby commented 6 years ago

@thomas15v for me it happens when I try to click "edit" website button on a page where there is no space for adding snippets. The code is on https://github.com/odoo/odoo/blob/11.0/addons/web_editor/static/src/js/widgets/widgets.js#L410

Yenthe666 commented 6 years ago

@ged-odoo still reproducable at my end on Odoo V9 with Chrome 64.0.3282.140 too: image I can trigger it from settings > email templates > opening an e-mail template and then clicking on the preview button.

alexisheloir commented 6 years ago

I also add to patch /web_editor/static/src/js/widgets.js l.552 to get the web editor widget working with the latest release of chrome.

    if (sheets[i].hasOwnProperty('rules')) {
        rules = sheets[i].rules;
Yenthe666 commented 6 years ago

@treviser, @thomas15v and @jakubhruby can you still reproduce it? It seems to been fixed at my end as of today.

lukebranch commented 6 years ago

FWIW i've also run into this all of a sudden on a stable version 9.0 deployment. This deployment has been coasting along smoothly with no changes other than occasional odoo-server updates for around 12 months.

I will pull the latest code and confirm if this fixes the issue as well.

xo2git commented 6 years ago

@Yenthe666 /web_editor/static/src/js/widgets.js also contains this error. It is used by the front-end web editor.

Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules at getCssSelectors (https://localhost/web/content/149290-d6b7fa2/web_editor.editor.js:142:89) at https://localhost/web/content/149290-d6b7fa2/web_editor.editor.js:145:120 at Function._.each._.forEach (https://localhost/web/content/84972-e647506/web.assets_common.js:12:558) at https://localhost/web/content/149290-d6b7fa2/web_editor.editor.js:145:77 at https://localhost/web/content/84972-e647506/web.assets_common.js:47:553 at Class.init (https://localhost/web/content/149290-d6b7fa2/web_editor.editor.js:145:349) at Class.init (https://localhost/web/content/84972-e647506/web.assets_common.js:2537:371) at new Class (https://localhost/web/content/84972-e647506/web.assets_common.js:2535:65) at Class.init (https://localhost/web/content/149290-d6b7fa2/web_editor.editor.js:14:1468) at Class.prototype.(anonymous function) (https://localhost/web/content/84972-e647506/web.assets_common.js:2534:559)

certiz commented 6 years ago

I applied first MouTio solution and it fixed the problem partially, but it keep happening in some places. After that I installed aek solution and it finish fixing the problem and know is working fine.

I recommend to use both solutions for a complete fix.

Thank you guys for your great help

MouTio commented 6 years ago

@certiz @lukebranch @Yenthe666

The solution is the same, but in different files. The bug was in more places but I only fixed it in the place where it crashed for me.

Now, it appears that they have fixed it in a stylish way, handling the exception with a try-catch:

a6e66131ce5b676ccc888ec5b1011d0946dc3907

If there is no more places with this bug, this issue is solved and it can be closed.

Yenthe666 commented 6 years ago

I think this should solve a lot. I'll close it for now. If anybody finds a new issue just respond.

jeremybramwell commented 6 years ago

Just found this issue when researching my own bug caused by chrome's change to throw an error when trying to access cssRules/rules on sheets that are from a different origin. I was going to try using .hasOwnProperty('rules') as a fix but it seems like all stylesheets return false for this. I guess rules is an inherited property.

So just a heads up that while it may prevent the exception that change may be breaking something else.

determin1st commented 6 years ago

This cant be fixed. At least, while mr.Google follows money oriented design. They locked that interface after IE6 failed. mr.IE had some currentStyle api. Now, in js-apocallypse they prefer to lock the new hope standard covering it (as usual) with "security" stuff.

gmarcon commented 6 years ago

Same issue with Odoo CE 10.0-20171227 and Chrome 66.0.3359.181 (Official Build) (64-bit)

Manually applying https://github.com/odoo/odoo/pull/22679/files fixes the issue

determin1st commented 6 years ago

You can also put it in try...catch block to suppress browser warning and check that .rules property

Yenthe666 commented 6 years ago

@gmarcon that is quite a long while without updating an Odoo too though 😉

determin1st commented 6 years ago

i dont even know what odoo is! just stucked in this notification. how to get out) backend is over, forget it! the future is for browser side

jpaulin commented 6 years ago

@ged-odoo I had similar error in Chrome with Odoo 10. Came down to removing a extension called Loom (video record / screen cap extension). When Loom was removed, Odoo no longer crashed.