Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1683)

Issue 6744050: Use skset to fix issue when pdf generates an exp number of resources (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by edisonn
Modified:
11 years, 1 month ago
CC:
skia-review_googlegroups.com, EricB
Base URL:
http://skia.googlecode.com/svn/trunk/
Visibility:
Public.

Description

Use SkSet to fix issue when pdf generates an exp number of resources. The problem fixed - http://code.google.com/p/skia/issues/detail?id=940 - is that getResources will recursively obtain all child resource recursively without checking for duplicates. If we have lots of duplicates, then we try to build a very large vector (exponential with the number of nodes usually) and sooner or later we end up using too much memory and crash. A possible solution could have been to make sure resources do not have duplicates, but that requirement is impractical, and it this leaves the solution fragile, if there is any issue in the tree, we crash. When we emit the pdf, the large number of duplicates is not an issue, because SkPDFCatalog::addObject will deal with duplicates. I have run the gm with --config pdf, and the images are 100% same bits, while the pdfs have the same size but some very small changes, the order of some objects. Committed: https://code.google.com/p/skia/source/detail?r=7883

Patch Set 1 #

Patch Set 2 : #

Total comments: 8

Patch Set 3 : #

Total comments: 8

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Patch Set 7 : #

Patch Set 8 : #

Patch Set 9 : #

Patch Set 10 : #

Total comments: 22

Patch Set 11 : #

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+193 lines, -124 lines) Patch
M include/pdf/SkPDFDevice.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +10 lines, -2 lines 2 comments Download
M include/pdf/SkPDFDocument.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +3 lines, -1 line 0 comments Download
M src/pdf/SkPDFCatalog.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +3 lines, -3 lines 0 comments Download
M src/pdf/SkPDFCatalog.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +15 lines, -12 lines 0 comments Download
M src/pdf/SkPDFDevice.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +41 lines, -22 lines 0 comments Download
M src/pdf/SkPDFDocument.cpp View 1 2 3 4 5 6 7 8 9 10 8 chunks +41 lines, -35 lines 6 comments Download
M src/pdf/SkPDFFont.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M src/pdf/SkPDFFont.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -2 lines 0 comments Download
M src/pdf/SkPDFFormXObject.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -2 lines 0 comments Download
M src/pdf/SkPDFFormXObject.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +8 lines, -12 lines 0 comments Download
M src/pdf/SkPDFGraphicState.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M src/pdf/SkPDFGraphicState.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -2 lines 0 comments Download
M src/pdf/SkPDFImage.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M src/pdf/SkPDFImage.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -2 lines 0 comments Download
M src/pdf/SkPDFPage.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -2 lines 0 comments Download
M src/pdf/SkPDFPage.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +3 lines, -2 lines 0 comments Download
M src/pdf/SkPDFShader.cpp View 1 2 3 4 5 6 7 8 9 10 3 chunks +12 lines, -6 lines 0 comments Download
M src/pdf/SkPDFTypes.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +19 lines, -9 lines 1 comment Download
M src/pdf/SkPDFTypes.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +15 lines, -7 lines 0 comments Download

Messages

Total messages: 15
edisonn
11 years, 8 months ago (2012-10-21 03:51:19 UTC) #1
edisonn
updated description, some rewording
11 years, 8 months ago (2012-10-21 03:56:18 UTC) #2
Steve VanDeBogart
https://codereview.appspot.com/6744050/diff/2001/src/pdf/SkPDFDocument.cpp File src/pdf/SkPDFDocument.cpp (right): https://codereview.appspot.com/6744050/diff/2001/src/pdf/SkPDFDocument.cpp#newcode21 src/pdf/SkPDFDocument.cpp:21: for (int i = firstIndex; i < resourceList->count(); i++) ...
11 years, 8 months ago (2012-10-21 07:05:03 UTC) #3
edisonn
https://codereview.appspot.com/6744050/diff/2001/src/pdf/SkPDFDocument.cpp File src/pdf/SkPDFDocument.cpp (right): https://codereview.appspot.com/6744050/diff/2001/src/pdf/SkPDFDocument.cpp#newcode21 src/pdf/SkPDFDocument.cpp:21: for (int i = firstIndex; i < resourceList->count(); i++) ...
11 years, 8 months ago (2012-10-22 17:19:38 UTC) #4
edisonn
ping
11 years, 8 months ago (2012-10-31 15:12:33 UTC) #5
reed1
https://codereview.appspot.com/6744050/diff/9001/include/pdf/SkPDFDevice.h File include/pdf/SkPDFDevice.h (right): https://codereview.appspot.com/6744050/diff/9001/include/pdf/SkPDFDevice.h#newcode135 include/pdf/SkPDFDevice.h:135: */ Seems like we don't *have* to use the ...
11 years, 8 months ago (2012-10-31 17:54:23 UTC) #6
Steve VanDeBogart
Looking through this change, it looks like the only methods of SkTPDFSet that are used ...
11 years, 8 months ago (2012-10-31 18:07:26 UTC) #7
edisonn
I updated the code to use a true Set. But the code is a little ...
11 years, 8 months ago (2012-11-02 20:22:02 UTC) #8
edisonn
https://codereview.appspot.com/6744050/diff/9001/src/pdf/SkPDFFormXObject.h File src/pdf/SkPDFFormXObject.h (right): https://codereview.appspot.com/6744050/diff/9001/src/pdf/SkPDFFormXObject.h#newcode16 src/pdf/SkPDFFormXObject.h:16: #include "SkTPDFSet.h" On 2012/10/31 18:07:26, Steve VanDeBogart wrote: > ...
11 years, 8 months ago (2012-11-02 20:23:40 UTC) #9
Steve VanDeBogart
https://codereview.appspot.com/6744050/diff/9001/src/pdf/SkPDFFormXObject.h File src/pdf/SkPDFFormXObject.h (right): https://codereview.appspot.com/6744050/diff/9001/src/pdf/SkPDFFormXObject.h#newcode16 src/pdf/SkPDFFormXObject.h:16: #include "SkTPDFSet.h" On 2012/11/02 20:23:40, edisonn wrote: > On ...
11 years, 7 months ago (2012-11-05 23:45:38 UTC) #10
edisonn
https://codereview.appspot.com/6744050/diff/9001/src/pdf/SkPDFFormXObject.h File src/pdf/SkPDFFormXObject.h (right): https://codereview.appspot.com/6744050/diff/9001/src/pdf/SkPDFFormXObject.h#newcode16 src/pdf/SkPDFFormXObject.h:16: #include "SkTPDFSet.h" On 2012/11/05 23:45:38, Steve VanDeBogart wrote: > ...
11 years, 4 months ago (2013-02-06 17:25:07 UTC) #11
Steve VanDeBogart
Just a few nits/clean ups. https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp File src/pdf/SkPDFDocument.cpp (right): https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp#newcode112 src/pdf/SkPDFDocument.cpp:112: SkASSERT(knownResources.mergeInto(*fFirstPageResources) == 0); On ...
11 years, 4 months ago (2013-02-06 19:28:55 UTC) #12
thakis
https://codereview.appspot.com/6744050/diff/32001/include/pdf/SkPDFDevice.h File include/pdf/SkPDFDevice.h (right): https://codereview.appspot.com/6744050/diff/32001/include/pdf/SkPDFDevice.h#newcode32 include/pdf/SkPDFDevice.h:32: template <typename T> class SK_API SkTSet; Do you need ...
11 years, 1 month ago (2013-06-03 18:22:43 UTC) #13
edisonn
https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp File src/pdf/SkPDFDocument.cpp (right): https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp#newcode112 src/pdf/SkPDFDocument.cpp:112: SkASSERT(knownResources.mergeInto(*fFirstPageResources) == 0); On 2013/02/06 19:28:55, Steve VanDeBogart wrote: ...
11 years, 1 month ago (2013-06-03 18:23:51 UTC) #14
thakis
11 years, 1 month ago (2013-06-03 18:24:54 UTC) #15
On Mon, Jun 3, 2013 at 11:23 AM, <edisonn@google.com> wrote:

>
> https://codereview.appspot.**com/6744050/diff/19003/src/**
>
pdf/SkPDFDocument.cpp<https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp>
> File src/pdf/SkPDFDocument.cpp (right):
>
> https://codereview.appspot.**com/6744050/diff/19003/src/**
>
pdf/SkPDFDocument.cpp#**newcode112<https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp#newcode112>
> src/pdf/SkPDFDocument.cpp:112:
> SkASSERT(knownResources.**mergeInto(***fFirstPageResources) == 0);
> On 2013/02/06 19:28:55, Steve VanDeBogart wrote:
>
>> On 2013/02/06 17:25:07, edisonn wrote:
>> > On 2012/11/05 23:45:38, Steve VanDeBogart wrote:
>> > > Shouldn't this be empty at this point?
>> >
>> > yep, and I should not be using SkASSERT, fixed lines below
>>
>
>   From flow control we can prove that both knownResources and
>>
> fFirstPageResoruces
>
>> are empty at this point, so you can just remove this line.
>>
>
> Done.
>
> https://codereview.appspot.**com/6744050/diff/19003/src/**
>
pdf/SkPDFDocument.cpp#**newcode117<https://codereview.appspot.com/6744050/diff/19003/src/pdf/SkPDFDocument.cpp#newcode117>
> src/pdf/SkPDFDocument.cpp:117: *fAllExceptFirstPageResources) == 0);
> On 2013/02/06 19:28:55, Steve VanDeBogart wrote:
>
>> On 2013/02/06 17:25:07, edisonn wrote:
>> > On 2012/11/05 23:45:38, Steve VanDeBogart wrote:
>> > > Similarly, shouldn't this be empty at this point?
>> >
>> > one can call emitPdf twice, so this one might not be empty
>>
>
>  But this code path is only called the first time emitPDF is called, so
>>
> you can
>
>> remove this line.
>>
>
> Done.
>
>
> https://codereview.appspot.**com/6744050/diff/32001/**
>
include/pdf/SkPDFDevice.h<https://codereview.appspot.com/6744050/diff/32001/include/pdf/SkPDFDevice.h>
> File include/pdf/SkPDFDevice.h (right):
>
> https://codereview.appspot.**com/6744050/diff/32001/**
>
include/pdf/SkPDFDevice.h#**newcode32<https://codereview.appspot.com/6744050/diff/32001/include/pdf/SkPDFDevice.h#newcode32>
> include/pdf/SkPDFDevice.h:32: template <typename T> class SK_API SkTSet;
> Already fixed. Thanks for feedback.


Ah, sorry. The version of skia that chromium uses doesn't have the fix yet.

Thanks for fixing!


>
>
> On 2013/06/03 18:22:43, thakis wrote:
>
>> Do you need the SK_API here? Usually these defines are put only on
>>
> type
>
>> definitions, not on declarations. If it's here, gcc 4.4 (and maybe
>>
> others) warn:
>
>  ../../third_party/skia/**include/pdf/SkPDFDevice.h:33: warning: type
>>
> attributes
>
>> ignored after type is already defined
>>
>
> https://codereview.appspot.**com/6744050/diff/32001/src/**
>
pdf/SkPDFDocument.cpp<https://codereview.appspot.com/6744050/diff/32001/src/pdf/SkPDFDocument.cpp>
> File src/pdf/SkPDFDocument.cpp (right):
>
> https://codereview.appspot.**com/6744050/diff/32001/src/**
>
pdf/SkPDFDocument.cpp#**newcode56<https://codereview.appspot.com/6744050/diff/32001/src/pdf/SkPDFDocument.cpp#newcode56>
> src/pdf/SkPDFDocument.cpp:56: fFirstPageResources =
> SkNEW(SkTSet<SkPDFObject*>);
> On 2013/02/06 19:28:55, Steve VanDeBogart wrote:
>
>> Allocate these in emitPDF() to make it clearer that they are not used
>>
> until
>
>> emitPDF() is called.
>>
>
> Done.
>
> https://codereview.appspot.**com/6744050/diff/32001/src/**
>
pdf/SkPDFDocument.cpp#**newcode117<https://codereview.appspot.com/6744050/diff/32001/src/pdf/SkPDFDocument.cpp#newcode117>
> src/pdf/SkPDFDocument.cpp:117: SkASSERT(duplicates == 0);           }
> On 2013/02/06 19:28:55, Steve VanDeBogart wrote:
>
>> Fix formatting here.
>>
>
> Done.
>
> https://codereview.appspot.**com/6744050/diff/32001/src/**
>
pdf/SkPDFDocument.cpp#**newcode119<https://codereview.appspot.com/6744050/diff/32001/src/pdf/SkPDFDocument.cpp#newcode119>
> src/pdf/SkPDFDocument.cpp:119: fPages[i]->finalizePage(
> On 2013/02/06 19:28:55, Steve VanDeBogart wrote:
>
>> The ownership of the resources returned is a bit muddled here.  I
>>
> agree with
>
>> your choice that it's not worth referencing them for knownResources
>>
> only
>
>> unreference them within emitPDF().  But please add a comment here or
>>
> maybe a bit
>
>> lower that the references returned in newResources are transfered to
>> fFirstPageResources or fOtherPageResources depending on firstPage and
>> knownResources doesn't have a reference but just relies on the other
>>
> two sets to
>
>> maintain a reference.
>>
>
> Done.
>
>
https://codereview.appspot.**com/6744050/<https://codereview.appspot.com/6744...
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b