[MacRuby-devel] PDFKit status?
Hi,
I'm wondering what the status of using PDFKit in MacRuby. Should it be fully
usable now? I encountered a possible bug.
framework 'cocoa'
framework 'Quartz'
path =
pdfDoc = PDFDocument.alloc.initWithURL(NSURL.fileURLWithPath(path))
selections = pdfDoc.findString("the",withOptions:NSCaseInsensitiveSearch)
selections.each do |selection|
p selection.string
end
=> NSInvalidArgumentException: -[CPCharacterIndex count]: unrecognized selector
sent to instance 0x200915a80 (RuntimeError Error)
The PDF I used is an academic journal article PDF with about 12000 words. This
occurred at different positions in the PDF file every time. Sometimes this
happens earlier in the loop and sometimes later. This did run a few times
without error (rarely, though). Whether or not to add .string didn't matter.
The same process works without any problem with RubyCocoa.
Best,
Yasu
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] PDFKit status?
Can you please file a ticket (find the info on the website) and maybe try to
reduce the problem to a few lines of code?
Thanks,
- Matt
Sent from my iPhone
On Dec 5, 2010, at 16:27, Yasu Imao wrote:
> Hi,
>
> I'm wondering what the status of using PDFKit in MacRuby. Should it be fully
> usable now? I encountered a possible bug.
>
>
> framework 'cocoa'
> framework 'Quartz'
>
> path =
>
> pdfDoc = PDFDocument.alloc.initWithURL(NSURL.fileURLWithPath(path))
> selections = pdfDoc.findString("the",withOptions:NSCaseInsensitiveSearch)
> selections.each do |selection|
> p selection.string
> end
>
> => NSInvalidArgumentException: -[CPCharacterIndex count]: unrecognized
> selector sent to instance 0x200915a80 (RuntimeError Error)
>
>
> The PDF I used is an academic journal article PDF with about 12000 words.
> This occurred at different positions in the PDF file every time. Sometimes
> this happens earlier in the loop and sometimes later. This did run a few
> times without error (rarely, though). Whether or not to add .string didn't
> matter. The same process works without any problem with RubyCocoa.
>
>
> Best,
> Yasu
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] PDFKit status?
Hi Yasu,
I tried your sample with a large pdf in my environment a few times and it never
crashed. But I suspect the exception you're getting is due to a memory problem,
maybe related to the GC.
Can you try setting the GC_DISABLE environment variable to 1 when running the
script?
If it doesn't crash anymore it's probably not a bug in MacRuby then. I would
try to rewrite the sample in pure Objective-C and see if the crash persists.
Laurent
On Dec 5, 2010, at 4:27 PM, Yasu Imao wrote:
> Hi,
>
> I'm wondering what the status of using PDFKit in MacRuby. Should it be fully
> usable now? I encountered a possible bug.
>
>
> framework 'cocoa'
> framework 'Quartz'
>
> path =
>
> pdfDoc = PDFDocument.alloc.initWithURL(NSURL.fileURLWithPath(path))
> selections = pdfDoc.findString("the",withOptions:NSCaseInsensitiveSearch)
> selections.each do |selection|
> p selection.string
> end
>
> => NSInvalidArgumentException: -[CPCharacterIndex count]: unrecognized
> selector sent to instance 0x200915a80 (RuntimeError Error)
>
>
> The PDF I used is an academic journal article PDF with about 12000 words.
> This occurred at different positions in the PDF file every time. Sometimes
> this happens earlier in the loop and sometimes later. This did run a few
> times without error (rarely, though). Whether or not to add .string didn't
> matter. The same process works without any problem with RubyCocoa.
>
>
> Best,
> Yasu
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] PDFKit status?
Hi Laurent and Matt,
I tried the script with GC_DISABLE=1 (I'm not sure if this is how it should be,
though), and with GC_DISABLE set to 1, the script run without any problem. As
with my first post, 'sample.pdf' is a 12000 word academic journal article PDF
in English.
I also tried .map{|x| x.string} as well as .each{} and got the same results
(error). I got error something like 9 out of 10 times. When I didn't use
block, the script run without any error (even without GC disabling)
Should I go ahead and file a ticket?
$ GC_DISABLE=1 macruby sample.rb
sample.rb
#!/usr/local/bin/macruby
framework 'cocoa';framework 'Quartz'
PDFDocument.alloc.initWithURL(NSURL.fileURLWithPath("sample.pdf")).findString("the",withOptions:NSCaseInsensitiveSearch).each{|x|
p x.string}
The error messages I got are (multiple, all while processing the block):
=> NSInvalidArgumentException: -[CPCharacterIndex count]: unrecognized selector
sent to instance (RuntimeError Error)
=> NSRangeException: *** -[NSCFArray objectAtIndex:]: index (220) beyond bounds
(2) (RuntimeError)
=> [CPZoneBorderIntersection count]: unrecognized selector sent to instance
=> Segmentation fault
Best,
Yasu
On 2010/12/06, at 11:50, Laurent Sansonetti wrote:
> Hi Yasu,
>
> I tried your sample with a large pdf in my environment a few times and it
> never crashed. But I suspect the exception you're getting is due to a memory
> problem, maybe related to the GC.
>
> Can you try setting the GC_DISABLE environment variable to 1 when running the
> script?
>
> If it doesn't crash anymore it's probably not a bug in MacRuby then. I would
> try to rewrite the sample in pure Objective-C and see if the crash persists.
>
> Laurent
>
> On Dec 5, 2010, at 4:27 PM, Yasu Imao wrote:
>
>> Hi,
>>
>> I'm wondering what the status of using PDFKit in MacRuby. Should it be
>> fully usable now? I encountered a possible bug.
>>
>>
>> framework 'cocoa'
>> framework 'Quartz'
>>
>> path =
>>
>> pdfDoc = PDFDocument.alloc.initWithURL(NSURL.fileURLWithPath(path))
>> selections = pdfDoc.findString("the",withOptions:NSCaseInsensitiveSearch)
>> selections.each do |selection|
>> p selection.string
>> end
>>
>> => NSInvalidArgumentException: -[CPCharacterIndex count]: unrecognized
>> selector sent to instance 0x200915a80 (RuntimeError Error)
>>
>>
>> The PDF I used is an academic journal article PDF with about 12000 words.
>> This occurred at different positions in the PDF file every time. Sometimes
>> this happens earlier in the loop and sometimes later. This did run a few
>> times without error (rarely, though). Whether or not to add .string didn't
>> matter. The same process works without any problem with RubyCocoa.
>>
>>
>> Best,
>> Yasu
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
