Skip to content

Commit 8e47760

Browse files
committed
Bug 1941838 - Fix a panic in prepare_quad when f32 rounding produces zero-size tasks r=gfx-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D236306
1 parent e0145b1 commit 8e47760

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

webrender/src/quad.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ pub fn prepare_quad(
450450

451451
let rect = int_rect.to_f32();
452452

453+
// At extreme scales the rect can round to zero size due to
454+
// f32 precision, causing a panic in new_dynamic, so just
455+
// skip segments that would produce zero size tasks.
456+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1941838#c13
457+
let int_rect_size = int_rect.round().to_i32().size();
458+
if int_rect_size.is_empty() {
459+
continue;
460+
}
461+
453462
if is_direct {
454463
scratch.quad_direct_segments.push(QuadSegment { rect: rect.cast_unit(), task_id: RenderTaskId::INVALID });
455464
} else {
@@ -480,7 +489,7 @@ pub fn prepare_quad(
480489

481490
let task_id = add_render_task_with_mask(
482491
&pattern,
483-
int_rect.round().to_i32().size(),
492+
int_rect_size,
484493
rect.min,
485494
clip_chain.clips_range,
486495
prim_spatial_node_index,

0 commit comments

Comments
 (0)