@@ -22,37 +22,13 @@ const applyScratchBlocksPerformancePatches = ScratchBlocks => {
2222 workspaceProto . pendingGridUpdateTimer_ = null ;
2323 workspaceProto . deferGridUpdate_ = false ;
2424
25- workspaceProto . setOffscreenTopBlockCullingEnabled = function ( enabled ) {
26- if ( this . offscreenTopBlockCullingEnabled_ === enabled ) {
27- if ( enabled ) this . queueIntersectionCheck ( ) ;
28- return ;
29- }
30- this . offscreenTopBlockCullingEnabled_ = enabled ;
31-
32- const topBlocks = this . getTopBlocks ( false ) ;
33- let needsFullRender = false ;
34- for ( const block of topBlocks ) {
35- if ( block . setIntersects ) block . setIntersects ( true ) ;
36- if ( ! enabled && block . deferredRenderPending_ ) {
37- needsFullRender = true ;
38- }
39- }
40-
41- if ( ! enabled && needsFullRender ) {
42- this . render ( ) ;
43- if ( ! this . isFlyout ) {
44- setTimeout ( ( ) => {
45- for ( const block of topBlocks ) {
46- if ( block . workspace ) {
47- block . setConnectionsHidden ( false ) ;
48- block . deferredRenderPending_ = false ;
49- }
50- }
51- } , 1 ) ;
52- }
53- }
54-
55- this . queueIntersectionCheck ( ) ;
25+ workspaceProto . setOffscreenTopBlockCullingEnabled = function ( ) {
26+ // Experimental top-block culling caused large projects to become
27+ // much slower than upstream TurboWarp/Scratch. Keep the original
28+ // full-render path by forcing this feature off.
29+ this . offscreenTopBlockCullingEnabled_ = false ;
30+ this . deferBlockRendering_ = false ;
31+ this . intersectionCheckPendingAfterDrag_ = false ;
5632 } ;
5733
5834 const originalTranslate = workspaceProto . translate ;
@@ -63,46 +39,9 @@ const applyScratchBlocksPerformancePatches = ScratchBlocks => {
6339 }
6440 } ;
6541
66- workspaceProto . ensureTopBlockRendered_ = function ( block ) {
67- if ( block . deferredRenderPending_ ) {
68- block . render ( false ) ;
69- block . deferredRenderPending_ = false ;
70- this . resizeContents ( ) ;
71- if ( ! this . isFlyout ) {
72- setTimeout ( ( ) => {
73- if ( block . workspace ) {
74- block . setConnectionsHidden ( false ) ;
75- }
76- } , 1 ) ;
77- }
78- return ;
79- }
80- if ( ! block . rendered ) {
81- block . render ( false ) ;
82- }
83- } ;
84-
85- workspaceProto . renderVisibleTopBlocks = function ( ) {
86- for ( const block of this . getTopBlocks ( false ) ) {
87- if ( this . isBlockInViewport_ && this . isBlockInViewport_ ( block ) ) {
88- this . ensureTopBlockRendered_ ( block ) ;
89- }
90- }
91- } ;
92-
93- workspaceProto . queueIntersectionCheck = function ( ) {
94- if ( ! this . offscreenTopBlockCullingEnabled_ ) return ;
95- if ( this . isDragSurfaceActive_ || ( this . isDragging && this . isDragging ( ) ) ) {
96- this . intersectionCheckPendingAfterDrag_ = true ;
97- return ;
98- }
99- if ( this . renderVisibleTopBlocks ) {
100- this . renderVisibleTopBlocks ( ) ;
101- }
102- if ( this . intersectionObserver ) {
103- this . intersectionObserver . queueIntersectionCheck ( ) ;
104- }
105- } ;
42+ workspaceProto . ensureTopBlockRendered_ = function ( ) { } ;
43+ workspaceProto . renderVisibleTopBlocks = function ( ) { } ;
44+ workspaceProto . queueIntersectionCheck = function ( ) { } ;
10645
10746 workspaceProto . scheduleWheelScroll_ = function ( deltaX , deltaY ) {
10847 if ( ! this . pendingWheelScrollDelta_ ) {
@@ -216,7 +155,7 @@ const applyScratchBlocksPerformancePatches = ScratchBlocks => {
216155 if ( this . flyout_ ) {
217156 this . flyout_ . reflow ( ) ;
218157 }
219- this . queueIntersectionCheck ( ) ;
158+ // Disabled experimental intersection/culling refresh.
220159 } ;
221160
222161 const originalWorkspaceDispose = workspaceProto . dispose ;
@@ -235,38 +174,17 @@ const applyScratchBlocksPerformancePatches = ScratchBlocks => {
235174 const originalResetDragSurface = workspaceProto . resetDragSurface ;
236175 workspaceProto . resetDragSurface = function ( ) {
237176 originalResetDragSurface . call ( this ) ;
238- if ( this . intersectionCheckPendingAfterDrag_ ) {
239- this . intersectionCheckPendingAfterDrag_ = false ;
240- this . queueIntersectionCheck ( ) ;
241- }
177+ this . intersectionCheckPendingAfterDrag_ = false ;
242178 } ;
243179 }
244180
245181 if ( intersectionProto ) {
246- const originalIntersectionDispose = intersectionProto . dispose ;
247- intersectionProto . dispose = function ( ) {
248- if ( this . intersectionCheckFrame_ !== null && this . intersectionCheckFrame_ !== undefined ) {
249- cancelAnimationFrame ( this . intersectionCheckFrame_ ) ;
250- this . intersectionCheckFrame_ = null ;
251- }
252- originalIntersectionDispose . call ( this ) ;
253- } ;
254-
255- intersectionProto . queueIntersectionCheck = function ( ) {
256- if ( this . intersectionCheckQueued ) return ;
257- this . intersectionCheckQueued = true ;
258- if ( window . requestAnimationFrame ) {
259- this . intersectionCheckFrame_ = window . requestAnimationFrame ( this . checkForIntersections ) ;
260- } else {
261- this . intersectionCheckFrame_ = setTimeout ( this . checkForIntersections , 16 ) ;
262- }
263- } ;
264-
265- const originalIntersectionCheck = intersectionProto . checkForIntersections ;
182+ intersectionProto . observe = function ( ) { } ;
183+ intersectionProto . unobserve = function ( ) { } ;
184+ intersectionProto . queueIntersectionCheck = function ( ) { } ;
266185 intersectionProto . checkForIntersections = function ( ) {
267186 this . intersectionCheckQueued = false ;
268187 this . intersectionCheckFrame_ = null ;
269- originalIntersectionCheck . call ( this ) ;
270188 } ;
271189 }
272190
@@ -325,12 +243,10 @@ const applyScratchBlocksPerformancePatches = ScratchBlocks => {
325243 }
326244
327245 if ( blockProto ) {
246+ blockProto . updateIntersectionObserver = function ( ) { } ;
328247 const originalInitSvg = blockProto . initSvg ;
329248 blockProto . initSvg = function ( ) {
330249 originalInitSvg . call ( this ) ;
331- if ( this . updateIntersectionObserver ) {
332- this . updateIntersectionObserver ( ) ;
333- }
334250 } ;
335251 }
336252
0 commit comments