Bug 113449 - numerical inconsistency in basegfx::utils::isInside() causes wrong clipping in PDF export
Summary: numerical inconsistency in basegfx::utils::isInside() causes wrong clipping i...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:pdf
Depends on:
Blocks: PDF-Export
  Show dependency treegraph
 
Reported: 2017-10-25 16:33 UTC by Michael Stahl (allotropia)
Modified: 2024-01-24 11:10 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
unit test for the failing call (1.10 KB, text/plain)
2017-10-25 16:36 UTC, Michael Stahl (allotropia)
Details
ridiculous hack that makes this document happy (729 bytes, text/plain)
2017-10-25 16:37 UTC, Michael Stahl (allotropia)
Details
minimised bugdoc for PDF export (21.76 KB, application/vnd.oasis.opendocument.presentation)
2017-10-25 16:39 UTC, Michael Stahl (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Stahl (allotropia) 2017-10-25 16:33:42 UTC
exporting the LO conference 2017 template to PDF results in wrong clipping on the Agenda page: there should be a vertical clip of the green group shape on the left, but the actual result is an un-clipped shape that extends into the text box as a triangle.

the PDF should contain this on the 2nd shape exported from drawPolyPolygon:
 0 0 307.5 595.2 re
 +W* n

but it's missing because the m_aClipRegion is empty at that point, because intersectClipRegion of these PolyPolygons results in [0:], i.e. empty:

%  XXX aOld [1:<4:(0,0)--(3075.02,0)--(3075.02,5952.76)--(0,5952.76)>]
%  XXX aRegion [1:<4:(-1276.72,-62.0787)--(3075.02,-62.0787)--(3075.02,6108.38)--(-1276.72,6108.38)>]

this is because of an inconsistency in basegfx::utils::isInside()
where isPointOnPolygon returns false (so it's not on the edge)
but then bCompXA is also false (because it's detected as equal to the edge),
so the isInside() wrongly returns false.

the problem is caused by a tiny difference in X,
3075.0236220472434 vs 3075.0236220472439

involved objects:

(rr) p *rCandidate.mpPolygon.m_pimpl
$33 = {
  m_value = {
    maPoints = {
      maVector = std::__debug::vector of length 4, capacity 4 = {{
          <basegfx::B2DPoint> = {
            <basegfx::B2DTuple> = {
              mfX = -1276.724409448819,
              mfY = -62.078740157480311
            }, <No data fields>}, <No data fields>}, {
          <basegfx::B2DPoint> = {
            <basegfx::B2DTuple> = {
              mfX = 3075.0236220472439,
              mfY = -62.078740157480311
            }, <No data fields>}, <No data fields>}, {
          <basegfx::B2DPoint> = {
            <basegfx::B2DTuple> = {
              mfX = 3075.0236220472439,
              mfY = 6108.3779527559054
            }, <No data fields>}, <No data fields>}, {
          <basegfx::B2DPoint> = {
            <basegfx::B2DTuple> = {
              mfX = -1276.724409448819,
              mfY = 6108.3779527559054
            }, <No data fields>}, <No data fields>}}
    },
    mpControlVector = std::unique_ptr<ControlVectorArray2D> containing 0x0,
    mpBufferedData = std::unique_ptr<ImplBufferedData> containing 0x7eee920,
    mbIsClosed = true
  }, 
  m_ref_count = 5
}

(rr) p aCurrentPoint
$40 = {
  <basegfx::B2DTuple> = {
    mfX = 3075.0236220472439,
    mfY = 6108.3779527559054
  }, <No data fields>}
(rr) p aPreviousPoint
$41 = {
  <basegfx::B2DTuple> = {
    mfX = 3075.0236220472439,
    mfY = -62.078740157480311
  }, <No data fields>}

(rr) p rPoint
$34 = (const basegfx::B2DPoint &) @0x7ffcc8ab2af0: {
  <basegfx::B2DTuple> = {
    mfX = 3075.0236220472434,
    mfY = 0
  }, <No data fields>}



the PDF export changed with commit 581806182ac7da81115c9675b4e828688178aa04
but it was differently wrong before that commit, the particular shape in the group shape was missing completely, and there is no problem with the commit.
Comment 1 Michael Stahl (allotropia) 2017-10-25 16:36:21 UTC
Created attachment 137290 [details]
unit test for the failing call

unit test to demonstrate the one call that causes all the trouble, run with
make CppunitTest_basegfx CPPUNIT_TEST_NAME="KeyStopLerpTest::testIsInside"
Comment 2 Michael Stahl (allotropia) 2017-10-25 16:37:28 UTC
Created attachment 137291 [details]
ridiculous hack that makes this document happy
Comment 3 Michael Stahl (allotropia) 2017-10-25 16:39:25 UTC
Created attachment 137292 [details]
minimised bugdoc for PDF export
Comment 4 Michael Stahl (allotropia) 2017-10-25 16:40:30 UTC
forgot to mention: i tried OOo 3.3 and the PDF export had the same issue.
Comment 5 QA Administrators 2018-10-27 02:54:56 UTC Comment hidden (obsolete)
Comment 6 Roman Kuznetsov 2019-03-16 20:36:38 UTC
Michael, are there any news about this bug?
Comment 7 Michael Stahl (allotropia) 2019-03-18 12:26:52 UTC
bug still happens on current master
Comment 8 Xisco Faulí 2019-03-18 20:04:57 UTC
(In reply to Michael Stahl (CIB) from comment #7)
> bug still happens on current master

Hi Michael,
Do you think we could turn this issue into an easyhack ?
Comment 9 QA Administrators 2022-01-23 03:42:29 UTC Comment hidden (obsolete)
Comment 10 QA Administrators 2024-01-24 03:12:48 UTC Comment hidden (obsolete)
Comment 11 Michael Stahl (allotropia) 2024-01-24 11:10:35 UTC
it looks like the problem is gone; suspect Armin fixed it but didn't tell anyone :)

i can still reproduce it in a downstream 6.1 branch, but not in a downstream 6.4 branch or current upstream branches.

the unit test in https://bugs.documentfoundation.org/attachment.cgi?id=137290 still fails however; don't have time to figure out which commit fixed it.