Live data from Hacker News

Everything about Google Translate crashing React (and other web apps)

martijnhols.nl

21–30 of 88 posts

Re: Everything about Google Translate crashing React (and other web apps)

#21

Earlier quoted context omitted.

I think the fundamental problem is you have two applications, the primary application and google translate altering the application state of the primary application at the same time, without any possible communication between the two regarding locking or alterations or anything. I'm pretty sure most applications in the history of computing would not fare any better if you constructed that situation.

The primary application is the browser. The problem here is that react "application" builds its own state of the web page, fails to reconcile it with changes to actual state, ends up in a detached state with stale information and then proceeds to alter actual state based on the corrupted information it has.

either that or the browser is the new OS, as people keep saying.

If there is such a thing as web apps, then the primary application is the web app, and that primary application runs in the browser.

Re: Everything about Google Translate crashing React (and other web apps)

#22
post #10

Earlier quoted context omitted.

Both Google and React are guilty here if i read the article right. Google replaces an element with a different element (Text with Font containing Text?), and React's virtual DOM keeps the old, deleted elements alive because the virtual DOM still references them. React "applications" would crash when Google Translate changes their stuff from under them if they didn't accidentally keep the old elements alive. Which wou…

Yeah, Google translate shouldn't have to "research"/reverse engineer, what kind of framework is being used on any random website it translates. It assuming, that it simply interacts with static information would still be a reasonable assumption. While Google translate is also at fault, if it changes the DOM structure. Why not leave things the same and just exchange textnodes? Seems silly.

I am just supposing, but have not checked, that if they change the text they must also change the DOM by at least changing the lang attribute on nodes affected, meaning probably the lang attribute on the html element, but could also be a lang attribute on each element wrapping a textNode.

on edit: I figured the article must have said something about this and I missed it, and yes, it shows that the DOM is changed to be lang="nl" on the html element, which means obviously if React rerenders but does not rerender the HTML element (which many React applications do not control) then the language would be out of sync, of course.

Re: Everything about Google Translate crashing React (and other web apps)

#25
post #10

Earlier quoted context omitted.

Both Google and React are guilty here if i read the article right. Google replaces an element with a different element (Text with Font containing Text?), and React's virtual DOM keeps the old, deleted elements alive because the virtual DOM still references them. React "applications" would crash when Google Translate changes their stuff from under them if they didn't accidentally keep the old elements alive. Which wou…

They both do reasonable things, so I wouldn't really blame either. Google Translate was there first and is a big accessibility advantage for the web. At the same time, Google Translate is the user-specific browser extension that is executed last, on top of existing apps. It affects not just React[1], so even if React were to implement a fix, Google Translate would continue to interfere with other webapps. I think any…

Obviously you could code your site for handling these kinds of linguistic difficulties (text longer or shorter) but its been my experience even sites that are supposed to be internationalized do not do a good enough job of taking cross-language display difficulties into consideration, so I don't think people will think, sure my site is in English, but what if Google Translate turns it into Greenlandic?

Re: Everything about Google Translate crashing React (and other web apps)

#27
post #3

So the fundamental problem is the DOM is too inefficient to do applications on it. No surprise there, considering the original design of HTML was for presenting information, not for interactive applications.

That hasn’t been true for at a minimum half a decade now and much longer in practice I think.

Re: Everything about Google Translate crashing React (and other web apps)

#30
post #3

So the fundamental problem is the DOM is too inefficient to do applications on it. No surprise there, considering the original design of HTML was for presenting information, not for interactive applications.

I doubt it. Say you write a native app and some other side app swoops in and changes all your UI state while running. That is going to cause problems.

But only, if the DOM is used in other ways than being an output of whatever is done to calculate its update. If the framework uses the DOM for other things than directly updating it or respresentation of internal state, then that's on the framework. Is it reasonable to assume DOM itself is part of the state? Would it not be more reasonable to have an internal state? But we have this with virtual DOM. So maybe the issue is in the way it makes use of the DOM in conjuction with virtual DOM internally. Maybe it is an optimization "hack" that goes badly in this scenario.
Post reply on HN