10 ms·
I think I don't understand the issue well enough. This looks like a standard blinking cursor to me. Users expect a blinking cursor in an editable text field. I
by Touche 10y ago
I think I don't understand the issue well enough. This looks like a standard blinking cursor to me. Users expect a blinking cursor in an editable text field.
I'm not sure why this implementation is slow or why they needed to implement it themselves and not let the OS handle the blinking cursor. I'm guessing there must be some reason.
- nolok 10y ago> I'm not sure why this implementation is slow I'm guessing the culprit for that is in this part of the bug report: > Zooming into a single frame, we see that while we render only 2 fps, the main thread is performing some work at 60 fps (every 16 ms) As for > why they needed to implement it themselves and not let the OS handle the blinking cursor They're not editing inside a text editor field anymore, they need to blink on html. I guess they're not using a deprecated <blink> tag is because it's not customizable in any way.
- kibwen 10y agoI don't believe that any modern browser still supports the blink tag; IIRC Firefox was the last to get rid of it, a year or two ago. You can hack it up in CSS, though.
- ethbro 10y agoTruly, the web has come full circle.
- Touche 10y agoThanks, so they are probably not using a contenteditable element. In that case it makes sense that they would need to use a CSS animation to blink the cursor.
- Mister_Snuggles 10y agoOn Win32[0], the blinking caret can be shown anywhere inside a window, not just on a text field. The sample program builds a basic text editor without cheating and using a textbox control. I'm sure other operating systems have this kind of facility - after all, how does the built in text edit control draw its caret? [0] https://msdn.microsoft.com/en-us/library/windows/desktop/ms648398(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
- coldtea 10y ago>On Win32[0], the blinking caret can be shown anywhere inside a window, not just on a text field. (...) I'm sure other operating systems have this kind of facility - after all, how does the built in text edit control draw its caret? The "built in text edit control" IS a native text field already.
- Mister_Snuggles 10y agoMy point is that the built-in text edit control needs some way to draw it's caret, so surely a universal method to draw a blinking caret exists somewhere.
- coldtea 10y agoWell, they could just make a C extension to Electron that draws a blinking colored line (that's all it is) using the OSes arbitrary drawing facilities. No need to have an official OS caret function (especially if you're not a native text field, and caret aside, the rest of your text editing will be different/broken in subtle ways compared to the OS).
- Someone 10y agoI'm not aware of any system where one can create that caret without a text edit control to hold it. That means that, if the standard text edit control isn't suited for what you want to do, you can't have the caret. Certainly, on the original Mac OS (a system on which I worked on OS patches for detecting the location of the caret) the method that application used for drawing the caret varied widely. I've seen it implemented by drawing a line, by drawing a rectangle, either in one go or in two parts (that happened in applications that supported a split caret, even if the caret wasn't split), with various transfer modes. Slanted carets typically were application-specific, too.
- Mister_Snuggles 10y ago> I'm not aware of any system where one can create that caret without a text edit control to hold it. Windows allows this. In a parent comment I posted a link to the API docs. All Windows requires is a window to hold the caret, it doesn't care what kind of window it is.
- azrazalea 10y ago> why they needed to implement it themselves and not let the OS handle the blinking cursor. Probably because they are using electron.
- billconan 10y agothis is exactly the same problem I met yesterday. I made a webpage based on a bootstrap template On this webpage, I have 2 realtime components. one is a chart, based on dygraphs the other component is a bootstrap progressbar. the bootstrap progressbar is made by html divs: https://www.w3schools.com/Bootstrap/bootstrap_progressbars.asp https://www.w3schools.com/Bootstrap/bootstrap_progressbars.a... Both components are updated in realtime by a websocket. I noticed that the chart by itself is very fast. But as soon as the progressbar is added, the entire webpage and even the entire machine becomes very slow. I guess this is because every bit of progressbar update, the browser rerender the entire page, as the progressbar is a div. I don't know how to solve this. I thought about using react for its virtual dom. but if eventually I need to update the dom, the speed seems to be the same.
- scriptproof 10y agoThere is an HTML 5 progress tag supported by all browsers: <progress id="" max=100>
- jinglebells 10y agoCan you buffer the incoming websockets data and only update at a small percentage of the inputs or maybe based on time? Lodash has a debounce function which is useful to throttle UI features hooked to incoming data. https://css-tricks.com/debouncing-throttling-explained-examples/ https://css-tricks.com/debouncing-throttling-explained-examp... You never really want the UI repaint to be dictated by data, it's better to use timers.
- paulirish 10y agoPowerful* text editors built on the web stack cannot rely on the OS text caret and have to provide their own. In this case, VSCode is probably using the most reasonable approach to blinking a cursor: a `step` timing-function with a CSS keyframe animation. This tells the browser to only change the opacity every 500ms. Meanwhile, Chrome hasn't yet optimised this completely yet, hence http://crbug.com/361587 http://crbug.com/361587. So currently, Chrome is doing the full rendering lifecycle (style, paint, layers) every 16ms when it should be only doing that work at a 500ms interval. I'm confident that the engineers working on Chrome's style components can sort this out, but it'll take a little bit of work. I think the added visibility on this topic will likely escalate the priority of the fix. :) * Simple text editors, and basic ones built on [contenteditable] can, but those rarely scale to the feature set most want. (I work on the Chrome team, though not on the rendering engine)
- Kristine1975 10y ago>http://crbug.com/361587 http://crbug.com/361587 Reported almost 3 years ago and still not fixed...
- pcwalton 10y agoWhy are you even painting at all instead of layerizing it? (This is a perfect example of what I've been increasingly convinced of lately: that the whole "paint"/"compositing" distinction hurts the Web…)
- phkahler 10y ago>> Powerful* text editors built on the web stack cannot rely on the OS text caret and have to provide their own. Powerful features do not require retarded implementations.
- Mister_Snuggles 10y ago> Powerful* text editors built on the web stack cannot rely on the OS text caret and have to provide their own. Is there any reason that Electron couldn't provide an API that would expose the system caret in an OS-agnostic manner? Windows, for example, has an API[0] that can arbitrarily show the caret at a given point in the window. Sounds like something that would be useful to many apps and not get in the way for those that don't need it. [0] https://msdn.microsoft.com/en-us/library/windows/desktop/ms648398(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
- fegu 10y agoAm I the only one around here who prefers a nonblinking cursor. That and key repeat rate are my first setting on any new install.