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

fix(): abort concurrent rendering #8218

Closed
wants to merge 11 commits into from
Closed

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Aug 30, 2022

This fix introduces the ability to abort a concurrent render cycle by calling abortRendering

Probably fixes a lot of issues that were reported on calling "XXX" on null ctx that were silenced because of qunit

It committed whitespace without my intention. And I don't want to pick out the trouble. Isn't there a git cmd to revert whitespace? Sound useful

@github-actions
Copy link
Contributor

github-actions bot commented Aug 30, 2022

Coverage after merging abort-concurrent-render into master will be

80.90%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
dist
   fabric.js79.15%75.11%84.74%80.90%10017, 10029, 10043, 10072, 10089–10090, 10093, 10102–10103, 10103, 10103–10104, 10106–10108, 10115, 10115, 10115–10117, 10119–10120, 10127–10129, 10156–10158, 10160–10161, 10164–10165, 10236, 10255–10257, 10259–10260, 10322, 10376, 10391, 10447, 10483–10484, 10490, 10494–10495, 10510, 10544, 10575–10576, 10600, 10608, 1069, 10695, 10727–10728, 10803–10804, 10807, 10812, 10834, 10834, 10834, 10834, 10834, 10834, 10834–10835, 10837–10838, 10838, 10838–10839, 10844, 10846, 10852, 10852, 10852, 10852, 10852–10853, 10855–10859, 10859, 10859–10861, 10863–10864, 10873, 10884, 10895, 10906, 10916–10919, 10927–10928, 10928, 10928–10929, 10931–10932, 10939, 10943, 1144, 1146–1147, 1149–1150, 11540, 11545, 1157, 11587–11589, 11589, 11589, 11589, 11589, 11589–11590, 1161, 11610, 11615–11616, 11656, 11656, 11656, 11656, 11684, 11684, 11684, 11686, 1169, 11834–11835, 11846, 12003–12004, 12011, 1205, 12054, 12061, 12061, 1207, 1207, 1207, 1207, 1207, 12070–12071, 1208, 12082, 12122, 12130, 12149–12151, 12178–12179, 12182, 12182, 12199–12201, 12304, 12389–12390, 12392–12393, 12400, 12424, 12489–12490, 12494, 12574, 12583, 12588, 12625, 12726, 12726, 12726, 12750–12751, 12859, 12862, 12924, 12930, 12937, 12944, 12950, 12956, 12963, 12970, 12976–12977, 12977, 12977, 12992–12993, 13001, 13010, 13010, 13035–13038, 13077, 13120–13121, 13161–13162, 13295–13296, 13441, 13533, 13596, 13599, 13652–13653, 13653, 13653, 13656, 13671, 13685, 13697–13698, 13700, 13712–13713, 13715, 13730, 1374, 1374, 13745–13746, 13748–13749, 13751–13752, 1376, 13762, 13792, 13792, 13792, 13792, 13792, 13792, 13792, 13792, 13817, 13819, 13819–13821, 13874–13876, 13899, 13907, 13913–13914, 13955, 14018–14019, 14053, 14074–14075, 14134, 14134, 14134, 14134, 14134, 14139–14147, 14189, 1426, 14315–14316, 14352, 14361, 14382, 14382, 14382–14383, 14383, 14383, 14383, 14383–14384, 14390–14392, 14395–14396, 14409, 14409, 14409–14410, 14410, 14410, 14410, 14410–14411, 14417–14419, 14422–14423, 14436–14437, 14511, 14560, 14564, 14689, 14719–14720, 14720, 14720–14721, 14721, 14721–14722, 14724, 14724, 14724–14725, 14728, 14735, 14820, 14933, 14982, 15052, 15056, 15126, 15183–15184, 15198, 15248–15249, 15251–15252, 15344, 15404, 15407, 1546, 15482, 15485, 15500–15501, 15510, 15552, 15556, 15581–15582, 15616, 15620, 15886, 15890, 16054, 16057, 16064–16065, 16065, 16065–16067, 16069, 16069, 16069, 1607, 16070–16071, 16071, 16071–16073, 16163, 16168–16170, 16198–16199, 16266, 16269, 16269, 16269–16270, 16272–16273, 16273, 16273–16274, 16274, 16274, 16276–16277, 16279, 16282, 16309, 16309–16311, 16360, 16360, 16395, 16430, 16430, 16430, 16433–16434, 16436, 16436, 16440, 16443, 16446, 16448–16449, 16458, 16463, 16463–16465, 16465, 16476–16477, 16486, 16486, 16486, 16486, 16486–16487, 16487, 16487–16489, 16489–16490, 16490, 16507–16508, 16508, 16508, 16530–16531, 16531, 16531, 16531, 16531, 16531, 16543, 16543, 16546–16550, 16550, 16589, 16628, 16660, 16663–16666, 16676, 16689, 16704, 16721, 16730, 16734, 16786, 16788–16790, 16804, 16806–16807, 16823, 16875, 16898, 17031, 17093–17095, 17095–17096, 17096, 17124, 17169–17172, 17179, 1718, 17181–17182, 1719, 17197–17199, 17209, 17209, 17209, 17272, 17284, 17284, 17331–17332, 17350–17351, 17372, 17414, 17414–17415, 17432–17435, 17435, 17435–17436, 17438, 17438, 17438–17439, 17441–17442, 17442, 17442–17443, 17445, 17445, 17445–17446, 17448–17449, 17453–17454, 17501, 17545, 176, 17614, 17619, 17643–17644, 17653–17657, 17669–17672, 17677, 17686–17687, 17689, 17698, 17698, 17698, 17698, 17698–17699, 17701–17702, 17718–17719, 17721–17722, 17729–17732, 17735, 17738, 17740–17741, 17741, 17741, 17741, 17741, 17741, 17741–17742, 17744, 17746–17747, 17747, 17747–17750, 17752, 17759–17767, 17767, 17767–17769, 17772, 17780–17783, 17789–17790, 17790, 17790–17791, 17793, 17793, 17793–17794, 17796, 17798–17799, 17814, 17816, 17816, 17816–17817, 17819–17820, 17820–17821, 17821, 17827, 17827, 17829, 17829–17830, 17830, 17839–17841, 17841, 17841–17849, 17855, 17855, 17855–17857, 17859, 17865–17866, 17880–17886, 17886, 17886–17887, 17890, 17892, 179, 17904, 17904, 17904–17905, 17908–17910, 17920, 17920, 17920–17922, 17934, 17934, 17934–17935, 17937–17938, 17938, 17938–17939, 17941–17942, 17942, 17942–17945, 17945, 17945–17946, 17948, 17948, 17948–17949, 17952–17953, 17956, 17958–17959, 17959, 17959, 17959,

@ShaMan123 ShaMan123 requested a review from asturur August 30, 2022 14:15
@asturur
Copy link
Member

asturur commented Aug 30, 2022

I don't like this change.
A render is not abortable.
A render either is not started yet, or is started. And once is started, it will finish because there is no time to interrupt it.
cancelAnimationFrame should work, and if it doesn't work and this change does, is probably because we are adding extra code in front of it that is giving time to execute things, while we want just to render as fast as possible.

This fix introduces the ability to abort a concurrent render cycle by calling abortRendering

Probably fixes a lot of issues that were reported on calling "XXX" on null ctx that were silenced because of qunit

It committed whitespace without my intention. And I don't want to pick out the trouble. Isn't there a git cmd to revert whitespace? Sound useful

There is an option to hide the whitespace changes that is good enough.
Prettier or lint are exactly to avoid those things

Copy link
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ready to me
Please look at the second comment closely

@@ -703,7 +687,23 @@ import { removeFromArray } from './util/internals';
*/
requestRenderAll: function () {
if (!this.isRendering) {
this.isRendering = fabric.util.requestAnimFrame(this.renderAndResetBound);
new Promise((resolve, reject) => {
const controller = new AbortController();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polyfill needed for node<16

@@ -748,7 +763,6 @@ import { removeFromArray } from './util/internals';
*/
renderCanvas: function(ctx, objects) {
var v = this.viewportTransform, path = this.clipPath;
this.cancelRequestedRender();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an important fix
Before, if you would called Canvas#toCanvasElement it would have cancelled requested renders. Or was it intentional.
I guess now there could be some nasty race condition.

@ShaMan123
Copy link
Contributor Author

we had a concurrent review it seems

FYI it did abort it. Not only took more time.
But you convinced me.

@ShaMan123 ShaMan123 closed this Aug 30, 2022
@ShaMan123 ShaMan123 deleted the abort-concurrent-render branch February 5, 2023 05:42
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

Successfully merging this pull request may close these issues.

2 participants