Comments (4)
How to use DevTools:
2022-09-28.09.45.07.mov
from flutter-code-editor.
Flutter code editor performance research
Source data
web-renderer: canvaskit
build mode: profile (release mode misuse here because compiler hide methods names, so we can’t recognize them in devtools)
language: python
theme: monokai-sublime
code: copy-pasted several times MinimalWordCount example. (2058 rows total)
testing actions: change cursor position and add symbol
Changing cursor position took about 545 ms for 2 largest events. Call stack of both of them mostly belongs to flutter source code, so we can’t handle it.
Adding symbol took about 847 ms for 2 largest events. We can work with about 10% of this time, another one flutter uses for layouting.
What already has been tried:
- Tried to find custom textfield for our requirements
- Tried to change current textfield properties for better performance
Possible ways to improve
- Splitting one big textfield on textfields list
- Set to textfield just visible text with extra viewport at top and bottom for smooth scrolling
from flutter-code-editor.
Highlighted is the current overhead of the comment parser, the foldable block parser, and other add-ons of ours. Hence we don't plan to optimize them. Improvements must be done in the Flutter part if we want them.
Keeping this open.
from flutter-code-editor.
- Seems like I duplicated this issue here #170
Little summary from the "discussion" from there.
TextField
uses TextPainter
inside, which takes a long time to layout if the text is huge. As I found, there is no way to affect to this.
TextPainter.layout()
-> expensive
TextPainter.paint()
-> cheap (can only be called after layout)
If we try to use CustomPaint with caching TextPainters
to make efficient use of them, it still scales quickly enough to become laggy at 700 lines of code.
Using ListView.builder
to display only visible lines doesn't work for some reason.
Even though ListView.builder
documentation says that it builds the widgets on demand, that is not what I actually experienced when testing it. It was even more laggy than CustomPaint
approach.
Finally, the solution that is similar to ListView.builder
-> CustomScrollView
with slivers.
This actually builds only those widgets, that are currently visible on the ViewPort. I believe this will allow us to reach maximum performance, as well as a whole bunch of new opportunities:
- Drawing indentation indicators
- Drawing errors indicators on the text position
- Drawing anything along with the text. (like folded block indicators, helper comments like flutter widgets etc.)
- Expose API for painting on the
TextField
so that users can do whatever they want on it.
Although, I also like the solution proposed by @Malarg, to split the TextField
into many TextFields
. That will definitely work.
But that implementation is also hard, while not providing other benefits apart from performance.
from flutter-code-editor.
Related Issues (20)
- Drop support for Flutter < 3.10
- Speed up the editor without highlighting
- Backspace does not work before a folded block HOT 1
- Line Numbers are not aligned with code HOT 5
- Null check operator used on a null value HOT 1
- [BUG] Code sections isn't working for Javascript language
- use latest http pakage
- Performance issues can occur if the number of rows exceeds a few hundred HOT 1
- Line Numbers escape the widget HOT 3
- Limit the variability of TextStyle in the gutter
- iOS: Gutter shifted up from the text HOT 7
- Material 3 causes progressing misalignment in code and line numbers HOT 1
- Maintenance status?
- Performance issue for long text HOT 5
- Does flutter-code-editor suppoert flutter-highlight? HOT 1
- how can i add a not exist language
- extend example so that code written can be executed
- Line numbers HOT 2
- Package doesn't works with Flutter 3.22 WASM update HOT 6
- [question] Autocomplete transparency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-code-editor.