Skip to content
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

p.a.mosaic 3.0.x, Plone 6.0.2 TinyMCE does half of the time not get initialised in tile edit modals #528

Closed
fredvd opened this issue Mar 13, 2023 · 8 comments
Assignees

Comments

@fredvd
Copy link
Sponsor Member

fredvd commented Mar 13, 2023

In a project I am upgrading from Plone 5.2. to Plone 6.0 we have some custom tiles with multiple RichText fields. Sometimes, about 50% the tinymce doesn't get initialised for any of the richtext fields in the browser and you only see the mimetypeselector:

tinymce richtextfieldwidget

When reloading loading the mosaic edit page and again clicking on the edit, shows a completely random but about 40-60% chance of tinymce loading. If I also keep the network tab open in the browser and monitor loaded js resources, the times the initialisation fails, I consistently see a failed 404 request for:

http://localhost:8080/nl/++webresource++fd4360ae-bfad-5886-999c-a1c8440f3377/++plone++static/bundle-plone/chunks/themes/silver/theme.min.js%E2%80%9D

If I don't see the error that this resources cannot be loaded, TinyMCE works. According to @petschki who assisted me with some debugging on Discord, this separate resource has been removed from the tinymce pattern and should be loaded directly. -> https://github.com/plone/mockup/blob/master/src/pat/tinymce/tinymce--implementation.js#L168


Digging further, I can check the initiator and stack trace of the silver/theme.min.js chunk that's no longer there:

stack-trace-wrong-resource-load

From that stack trace I can jump to the exact line that inserts/starts the load, which is here. If I put a breakpoint on that line and reload the page a few times, every time I hit the breakpoint and the passed resource to load is the silver/theme.min.js the tinymce init will fail when I resume from the breakpoint

tinymce-breakpoint-themeresourceload

Also a bit surprising, half of the times when refreshing the page, the breakpoint on the line to load the resource will instead show this resource to load, nd then tinymce initialisation works.

http://localhost:8080/nl/++webresource++fd4360ae-bfad-5886-999c-a1c8440f3377/++plone++static/bundle-plone/chunks/langs/nl.js


Possibly releated issues

  • This issue was opened in January by @frapell where he describes that tinynmce chunks get reloaded when they should already be present in the browser. With the behaviors descrribed above it also seems like non deterministically 'old' or different versions of tinymce get loaded.
    Are we using Webpack's Module Federation correctly? #515

I tried to debug this by having 2 browser windows opened on the network tab, filtering on .min.js javascript resources and creating a working and non working reload next to each other. Then I sorted on the filename and compared EACH of the 50-60 resources. ALL THE SAME chunks get loaded, only the extra silver/theme.min.js 404 is present in the browser network list where TinyMCE doesn't initialise in the modal.

That seems to bust the theory that a different tinymce gets loaded, but the ordering is somewhat different in each browser refresh, so a race condition could still be there depending on the loading order and that tinymce's from both bundles (mosaic-remote and plone-bundle-remote) get loaded always.

@jensens @thet Something is going on here, but I can't get my digital finger on it yet.

@fredvd
Copy link
Sponsor Member Author

fredvd commented Mar 13, 2023

One follow up. I did deploy the project to a testing environment. In production mode, I never see the silver/theme.min.js being attempted to load with a 404 and the tinymce initialisation always succeeds.

Locally on my dev machine I have both branches of plone.staticresources 2.0.x and plone.app.mosaic 3.0.x checked out and that is where I see the failures happening, either in debug mode or in production mode locally.

I get the feeling there is something wrong with the caches or with the chunks/generated webresources in the source checkouts when running locally in development mode. Unfortunately plone.app.mosaic doesn't build the resources locally at the moment (#527)

@jensens
Copy link
Sponsor Member

jensens commented Mar 14, 2023

Some month ago with 6.0.0 I had the same effect, but it seems to be gone now, so I was the opinion its solved.
Wild guesses what could be wrong:

  • do we have async loading here and a timing problem?
  • are the chunks fine and loaded in order?

Moreover, webresource is a dumb piece of software, creating a dependency tree of the resources given, calculating a hash to insert in the URL and delivering a HTML snippet. That is it.

@mauritsvanrees
Copy link
Sponsor Member

I am seeing this today as well in a project I am migrating from Plone 5.2 to 6.0.
Mosaic 3.0.1, Plone 6.0.3, both in debug mode and production mode.

  • Sometimes I get the 404 for silver/theme.min.js
  • Sometimes there is no tinymce popup when I click in a rich text field
  • Those two do not always happen at the same time: sometimes I get a 404 but tinymce does pop up. In fact, this seems to be the case most of the time.

@petschki
Copy link
Member

petschki commented Apr 21, 2023

So if I understand correctly there are actually two different issues here: fred initially talked about TinyMCE within modals not showing up -> this is caused by pat-textareamimetypeselector which I (think) fixed here: plone/mockup#1309

The second issue by @mauritsvanrees that the inline editor toolbar not showing up randomly is something different and I need to dig through mosaics tiny initialization process ...

@thet
Copy link
Member

thet commented Apr 21, 2023

I‌ have another PR which might help here:
#535

And another problem:
#536
Can anyone confirm the problem? @petschki @fredvd @frapell ?

@petschki
Copy link
Member

petschki commented Jun 2, 2023

Latest releases in https://dist.plone.org/release/6.0.5/versions-ecosystem.cfg should fix this issue. Feedback welcome.

@mauritsvanrees
Copy link
Sponsor Member

I have not seen the issue myself anymore. Thanks!

@petschki
Copy link
Member

petschki commented Jul 4, 2023

Since Plone 6.0.6 we have switched to mosaic 3.1.x which should have fixed those problems permanently. @fredvd I'll close this ticket, but feel free to reopen or open a new one if you have still problems.

@petschki petschki closed this as completed Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants