-
Notifications
You must be signed in to change notification settings - Fork 49
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
Parse xml synchronously #65
Comments
@Maatteogekko Do you have any benchmarks on how much synchronous parsing slows down the rendering and responsiveness of the application? |
I plan on testing it during this weekend, but just from a quick look at the performance tab of the dev tools it doesn't look bad (for a couple hundred characters at least) |
Ook here we go (better late than never 😅) For starters, I added a property to StyledText to choose between sync or async parsing (and I believe this could be a good solution). Screen.Recording.2023-02-19.at.11.04.54.mp4When I click on the top right arrow I call Now some benchmarks (ran on a physical device in profile mode). I first tried with a very long text, and then with a more reasonable one (for mobile apps at least). ~6000 charactersAsync versionasync_6000.movWe get 60 fps but there is the ugly jump both when first loading the page and when refreshing. Sync versionsync_6000.movWe still get 60 fps and there is no jump. But the frame where we parse the text janks pretty badly (30 to 50 ms). ~600 charactersAsync versionScreen.Recording.2023-02-19.at.11.42.22.movStill 60 fps and still jumps. Sync versionScreen.Recording.2023-02-19.at.11.44.23.movStill 60 fps and no jumps, but the frame where we parse now stays under 16ms There is a clear performance penalty when parsing the text synchronously, but I think in some cases (let's say with less than 500 characters of text) that is preferable to having the UI jump around. I am pretty sure that the synchronous parsing I quickly hacked together could be improved performance wise. What do you think? |
Also need this. Currently I have to wrap StyledTexts into SizedBoxes to avoid layout jumping |
@Maatteogekko I think you have make a great job of researching this issue. I agree with you that we need a parameter to enable synchronous parsing, but this will need to be documented and clearly explained when to use synchronous parsing and when not. |
Thank you @andyduke. How do we proceed from here? I can open a PR and then we can discuss things there? |
Any update? This is actually quite important. |
I have been using my fork for a while and have had no problems with going full sync (the latest commit on my fork removed the async parser for a faster sync parser). For implementing it in the package I am waiting for @andyduke directions |
@Maatteogekko @Pomis @LastMonopoly PS |
Nice!
be onParsed(node, false) ?
|
Yes, you are absolutly right. |
The only issue I have with this package is that it parses xml asynchronously. This makes widgets jump on first frame if they size themself according to the text (the simplest case is a Container wrapping some text).
This makes for a really poor user experience.
So I forked the xmlstream package and added a synchronous
read
method. Then used it in a fork of styled_text (here). I put it together quickly just for my use, but if anybody is interested I could polish it and make a PRThe text was updated successfully, but these errors were encountered: