You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2011/03/28 13:10:12 UTC

DO NOT REPLY [Bug 50985] New: Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

           Summary: Block elements inside inline elements that cause a
                    page break where the next page has a different IPD
                    causes NullPointerException
           Product: Fop
           Version: 1.1dev
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: page-master/layout
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: coolkidd3@hotmail.com


The attached test case creates the following NullPointerException:

java.lang.NullPointerException
        at
org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockListChangedIPD(AbstractBreaker.java:815)
        at
org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:428)
        at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:90)
        at
org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:107)
        at
org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:238)
        at
org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:120)
        at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:349)
        at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:177)
        at
org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1101)
        at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        at embedding.ExampleFO2PDF.convertFO2PDF(ExampleFO2PDF.java:91)
        at embedding.ExampleFO2PDF.main(ExampleFO2PDF.java:143)

This error occurs on FOP 1.0 and the latest version from the TRUNK.

The error gets resolved if I remove the text "Page 2", convert the inline to a
block or simply remove the left margin from the simple page master.

After looking into the code it appears that block elements that are inside
inline elements that cause a page break where the next page has a different IPD
is not supported. 

The getNextBlockListChangedIPD() function seems to be where it only looks at
for block elements and as a result keeps looking for something it will never
find (since the block is in an inline element).

Thanks

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #1 from coolkidd3@hotmail.com 2011-03-28 07:13:09 EDT ---
Created an attachment (id=26804)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26804)
This test checks two pages are created without a NullPointerException

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

coolkidd3@hotmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26818|0                           |1
        is obsolete|                            |

--- Comment #9 from coolkidd3@hotmail.com 2011-04-03 12:16:11 EDT ---
Created an attachment (id=26847)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26847)
Test case showing issues with IPD

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #6 from coolkidd3@hotmail.com 2011-03-30 15:24:37 EDT ---
Great, after applying the patch for Bug #44328; the PDF was created perfectly,
will test it again after you submit your updated pathtch for Bug #44328; but
for now my test case is working.

Thanks

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #3 from coolkidd3@hotmail.com 2011-03-30 13:33:46 EDT ---
Unfortunately the patch for Bug #50574 doesn’t resolve the issue for me.
Debugging the code shows that the lastRestartPosition variable is set to
positionAtBreak at line 767 and never used again. This will be because there is
only one page break in my test case.

The main issue seems to be that the positionAtBreak is set to the Second Block
element which has been initiated as a LeafNode. This results in the getPosition
function returning null and the subsequent getLM obviously fails thereafter on
line 824.

My knowldge of FOP's layout manager is limited so I have no idea why the Second
Block has been set to a leaf node when it clearly has children. 

Changing the Third Block from a self closing element to one that encapsulates
the "Page 2" text resolves the issue e.g:. 
<fo:flow flow-name="xsl-region-body" id="Flow">
    <fo:block id="First_Block">Page 1</fo:block>
    <fo:block id="Second_Block">
        <fo:inline id="First_Inline">
            <fo:block id="Third_Block">Page 2</fo:block>
        </fo:inline>
    </fo:block>
</fo:flow>

This will be due to the positionAtBreak variable being set to the Flow element
which does have children. 

Another example would be changing the first Inline element to a Block element:
<fo:page-sequence
    master-reference="chapter-master" master-name="chapter-master">
    <fo:flow flow-name="xsl-region-body" id="Flow">
        <fo:block id="First_Block">Page 1</fo:block>
        <fo:block id="Second_Block">
            <fo:block id="First_Inline">
                <fo:block id="Third_Block"/>Page 2
            </fo:block>
        </fo:block>
    </fo:flow>
</fo:page-sequence>

This sets the positionAtBreak variable to the newly changed block element which
has no problem getting its child Block.

I am not sure if there is a problem with the logic behind the positionAtBreak
variable e.g. should it be set to Flow instead of the Second Block? Or is it
the initialisation of the Second Block without any children?

Any ideas?
Thanks

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #11 from Andreas L. Delmelle <ad...@apache.org> 2011-04-03 14:20:03 EDT ---
(In reply to comment #9)
> Created an attachment (id=26847)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26847) [details]
> Test case showing issues with IPD

Did you also have the patch for 50574 applied? If I include that, it seems to
trigger an infinite loop... :-/

What we have here, is a tricky corner case. A combination of changing IPD and
at the same time, overflow in block-progression-direction. Something very
similar --but obviously not identical- to bug 50574. What it shows, is that my
proposed fix for 50574 is either not the right way to address this issue, or at
least, is incomplete.

In an overflow situation at the very first break --in this case: after an IPD
change-, the BreakingAlgorithm generates an auxiliary penalty at the start of
the element list to allow shifting the content to the next column/page if
possible. A new IPD change after page 2 results in an attempted restart from
that auxiliary break-possibility.

With the attempted fix for 50574, this would trigger an infinite series of
restarts, since we keep bumping into the overflow on every new page.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

coolkidd3@hotmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26804|0                           |1
        is obsolete|                            |

--- Comment #4 from coolkidd3@hotmail.com 2011-03-30 13:37:49 EDT ---
Created an attachment (id=26818)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26818)
This test checks two pages are created without a NullPointerException

Just updated the test case to include ID's on the Blocks and Inline elements so
they are easier to refer to in both code and discussion.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #13 from Glenn Adams <gl...@skynav.com> 2012-04-07 01:45:01 UTC ---
resetting P2 open bugs to P3 pending further review

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

Glenn Adams <gl...@skynav.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEEDINFO

--- Comment #12 from Glenn Adams <gl...@skynav.com> 2012-04-01 21:16:42 UTC ---
what is the status of this bug? can it be moved to resolved?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

Glenn Adams <gl...@skynav.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #7 from Andreas L. Delmelle <ad...@apache.org> 2011-03-31 15:00:09 EDT ---
(In reply to comment #6)
> Great, after applying the patch for Bug #44328; the PDF was created perfectly,

Good news. You can also try the patch I just attached there.

I will keep this bug open nevertheless. I somehow have a feeling that it may
just be a matter of finding the scenario that triggers this behavior again. All
we have established so far, is that it works as long as there is no
break-possibility between the empty block and the following text. 

If you feel like playing with the test case... :-) It could be as easy as just
adding 2 lines before and after the empty block. Widows/orphans will only apply
to those first and last lines, giving the algorithm a chance to break.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #10 from coolkidd3@hotmail.com 2011-04-03 12:20:52 EDT ---
Forgot to mention that this happens with the latest patch from Bug #44328; 
(including attachements; id=26843, id=26845 and id=26846)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

Andreas L. Delmelle <ad...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |

--- Comment #5 from Andreas L. Delmelle <ad...@apache.org> 2011-03-30 13:58:00 EDT ---

Aahh... OK, I think I see. Sorry, another local change on my end that is
responsible. See also Bug #44328; the patch currently there may not immediately
solve the problem, but I am going to post a new patch over there pretty soon.

If I am correct, by correcting widows/orphans control (default = 2 lines), the
zero-height line generated by the empty block should always move to the next
page with the following/last line. I already had a feeling that this was going
to resolve some ambiguous situations. This might be proof...

In the meantime, until you get a chance to verify on your end, I'll keep this
open.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

taffy-tyler6464@hotmail.co.uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |taffy-tyler6464@hotmail.co.
                   |                            |uk

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #14 from Glenn Adams <ga...@apache.org> 2012-04-24 05:35:55 UTC ---
(In reply to comment #12)
> what is the status of this bug? can it be moved to resolved?

andreas?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

--- Comment #8 from coolkidd3@hotmail.com 2011-04-03 12:11:49 EDT ---
(In reply to comment #7)
> If you feel like playing with the test case... :-) It could be as easy as just
> adding 2 lines before and after the empty block. Widows/orphans will only apply
> to those first and last lines, giving the algorithm a chance to break.

Yes, it broke as soon I added an extra line before or after Page 2, and both
cases gave the following error:

java.lang.UnsupportedOperationException: Don't know how to restart at
positionnull
        at
org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockListChangedIPD(AbstractBreaker.java:754)
        at
org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:428)
        at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:90)
        at
org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:107)
        at
org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:244)
        at
org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:120)
        at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:349)
        at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:177)

I will upload the updated test case which brings about this error

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 50985] Block elements inside inline elements that cause a page break where the next page has a different IPD causes NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50985

Andreas L. Delmelle <ad...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #2 from Andreas L. Delmelle <ad...@apache.org> 2011-03-29 20:37:52 EDT ---

Right... and on my end, it works without issues. I have a strong suspicion that
this is a duplicate of Bug #50574, for which I have the fix, but still need to
commit.

*** This bug has been marked as a duplicate of bug 50574 ***

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.