Bug 702012

Summary: Misplaced elements
Product: MuPDF Reporter: Krzysztof Kowalczyk <kkowalczyk>
Component: mupdfAssignee: MuPDF bugs <mupdf-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: master   
Hardware: PC   
OS: Windows 10   
Customer: Word Size: ---
Attachments: Repro file

Description Krzysztof Kowalczyk 2019-12-24 02:30:18 UTC
Created attachment 18741 [details]
Repro file

Originally reported against SumatraPDF: https://github.com/sumatrapdfreader/sumatrapdf/issues/1167

I verified it still happens in 1.16

On page 4 and 5, some parts are placed differently than e.g. Chrome (i.e. Foxit) or pdf.js
Comment 1 Tor Andersson 2020-01-03 14:12:47 UTC
This looks like a tiling pattern is not being correctly tiled.

The papyrus pattern background is only drawn once, and not stepped. The Matrix and XStep/YStep values and transform used during rendering are pretty extreme, so it may be related to precision issues or a forgotten transform somewhere.

The pattern dictionary for page 4 (object 47) has these entries:

  /BBox [ 0 0 1625600 1625600 ]
  /XStep 1625600
  /YStep 1625600
  /Matrix [ .00007559055 0 0 .00007559055 16.37504 168.7761 ]

And this content stream:

  q
  1625600 0 0 1625600 0 0 cm
  /Im8 Do
  Q
Comment 2 Tor Andersson 2025-10-08 13:22:28 UTC
commit d631871ba0584f32783b8a508b2d252bd707973b
Author: Tor Andersson <tor.andersson@artifex.com>
Date:   Wed Oct 8 14:30:20 2025 +0200

    Bug 702012: Increase precision of matrix inversion.
    
    The example file has a tiling pattern with a huge BBox and tiny Matrix.
    When we were inverting this we were running into FLT_EPSILON precision
    issues.
    
    Use doubles to invert matrixes like in fz_try_invert_matrix.
    
    Also return a degenerate (singularity) matrix when inversion fails,
    so it's easier to spot the cause for similar problems in the future.