Closed Bug 1152841 Opened 9 years ago Closed 9 years ago

PDF.js in Firefox OS is crashing but then have graphic glitch


(Firefox OS Graveyard :: Gaia::PDF Viewer, defect)

Gonk (Firefox OS)
Not set


(blocking-b2g:2.2+, b2g-v2.1 unaffected, b2g-v2.2 verified, b2g-master verified)

2.2 S10 (17apr)
blocking-b2g 2.2+
Tracking Status
b2g-v2.1 --- unaffected
b2g-v2.2 --- verified
b2g-master --- verified


(Reporter: clement.lefevre, Assigned: djf)



(Keywords: regression)


(5 files)

I just downloaded some PDFs I then got on the phone memory to read them later.

Then, by opening them through a file browser, it just happened to crash PDJ.js and create some graphic glitch making it impossible to access to the homescreen anymore.

It looks like it could be caused because it's opening the PDF inside the application.

Tested on

Build ID               20150408010203
Build Type             user
Gaia Revision          84cbd4391fb7175d5380fa72c04d68873ce77e6d
Gaia Date              2015-04-07 17:33:14
Gecko Revision
Gecko Version          40.0a1
Build Name             KVT49L dev-keys
Device ID              flame
Firmware(Release)      4.4.2
Firmware(Incremental)  39
Firmware Date          Thu Oct 16 18:19:14 CST 2014
Bootloader             L1TC00011880

See attachments for screen views.
It was, for example, tested withis this PDF (, but I tried others and problem was the same.
Reproduced on 2.2[1] with either the app "File manager" or "File" present on the Marketplace. 2.1[2] is not affected, you can close the PDF viewer without any glitch. However, the pdf file mentioned in comment 0 can't be visualized, the UI of the PDF viewer activity is not responsive. 

With both app, I see this particular line in the logcat. You have an example in attachment 8590798 [details]. 
W/PDF Viewer( 1324): [JavaScript Error: "Error: Invalid parameter array, need either .data or .url" {file: "app://" line: 254}]

In 2.1, I didn't see this line.

[1] Build ID               20150409162502
Gaia Revision          df0e04acad7c8c993f6ffe07b0ccb0ec20ee50bb
Gaia Date              2015-04-09 22:35:05
Gecko Revision
Gecko Version          37.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150409.200542
Firmware Date          Thu Apr  9 20:05:54 EDT 2015
Bootloader             L1TC000118D0

[2] Build ID               20150409161204
Gaia Revision          bbe983b4e8bebfec26b3726b79568a22d667223c
Gaia Date              2015-04-09 13:52:48
Gecko Revision
Gecko Version          34.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20141120.194707
Firmware Date          Thu Nov 20 19:47:17 EST 2014
Bootloader             L1TC00011880
Ever confirmed: true
Keywords: regression
[Blocking Requested - why for this release]: Regression which forces the user to reboot the phone to recover the homescreen.
blocking-b2g: --- → 2.2?
blocking-b2g: 2.2? → 2.2+
When I follow the STR, the home button works fine for me, both in master and 2.2.

I can't actually view my PDF file, and I do see the error in the logcat, but the home button still works.  No reboot is required.

It would be nice to fix this, but since the home button does not actually seem to be broken anymore, maybe this does not need to be a blocker.

QA: could you test this again? Also, is it actually a regression? Do pdfs display correctly in 2.1 when opened via a file manager app?
Keywords: qawanted
Assignee: nobody → dflanagan
Johan: does this patch fix the bug for you?
Flags: needinfo?(jlorenzo)
Comment on attachment 8592523 [details] [review]
[gaia] davidflanagan:bug1152841 > mozilla-b2g:master


Can you review this one-line patch for a 2.2+ blocker? Git blame says that you looked at this code less than a year ago.

The issue is that when 3rd party file manager apps use an open activity to view a PDF file, they send a blob and a filename, but not a URL. In this case fileURL is undefined in the activity handler but expects an object with a truthy originalURL property.  I opted for the simplest fix here of always passing a truthy value from the activity handler rather than trying to modify the open() method.

The README file for pdfjs says to modify the upstream repo, but I don't actually know if anyone is doing that.  It looks like the viewer.js upstream has the activity handler commented out, so maybe we just check this fix in directly?
Attachment #8592523 - Flags: review?(aus)
I am seeing the same results as David in comment 5 in Flame 3.0. I am seeing the error in logcat and the PDF indicated in comment 0 does not display, but the homescreen button works fine and there is no crash.

In Flame 2.1 the PDF does not open properly either from File Manager app (no crash though), but like 3.0 there is no issue with getting the home button to work. However, I do not see the same javascript error message in the log. There are a few other error messages that seem similar though:

04-14 17:00:17.444: E/GeckoConsole(1428): [JavaScript Error: "errorWrapper is null" {file: "app://" line: 4680}]
04-14 17:00:17.444: E/GeckoConsole(1428): [JavaScript Error: "NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS: [JavaScript Error: "errorWrapper is null" {file: "app://" line: 4680}]'[JavaScript Error: "errorWrapper is null" {file: "app://" line: 4680}]' when calling method: [nsIDOMSystemMessageCallback::handleMessage]" {file: "jar:file:///system/b2g/omni.ja!/components/SystemMessageManager.js" line: 93}]

Device: Flame 3.0 Master
Build ID: 20150414072436
Gaia: c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b
Gecko: 388f5861dc7d
Version: 40.0a1 (3.0)
Firmware Version: v18D-1
User Agent: Mozilla/5.0 (Mobile; rv:40.0) Gecko/40.0 Firefox/40.0

Device: Flame 2.1
Build ID: 20150414001210
Gaia: bbe983b4e8bebfec26b3726b79568a22d667223c
Gecko: 3e3cbe35bce3
Version: 34.0 (2.1)
Firmware Version: v18D-1
User Agent: Mozilla/5.0 (Mobile; rv:34.0) Gecko/34.0 Firefox/34.0
QA Whiteboard: [QAnalyst-Triage?]
Flags: needinfo?(ktucker)
Keywords: qawanted
QA Whiteboard: [QAnalyst-Triage?] → [QAnalyst-Triage+]
Flags: needinfo?(ktucker)
Thanks David for this patch, now I can see the PDF correctly displayed!

There is still the graphical glitch, though. It happens when the app gets closed like when you kill it with the task switcher. Here's a video showing the steps and the effects of it: Side note: I shot it before applying the patch. I tried the same steps with the patch applied, and I get into the same state. 

David, do you want to fix this separate issue in another bug?
Flags: needinfo?(jlorenzo) → needinfo?(dflanagan)

Yesterday I could not reproduce that other part of the bug, but today I can reproduce it, at least some of the time. That is much more than a "graphical glitch"!

It is a separate, more serious bug, I think. I'll file a new bug and will carry the 2.2+ forward on that new bug.
Flags: needinfo?(dflanagan)
I've filed 1154838 for the window management part of this bug.
Comment on attachment 8592523 [details] [review]
[gaia] davidflanagan:bug1152841 > mozilla-b2g:master

the change looks good to me, does pdf.js have tests? If so, we should ideally have a test for this change before final commit. r+ assumes we'll do the right thing with the test. :)
Attachment #8592523 - Flags: review?(aus) → review+
There aren't any existing PDF viewer tests that I can see, so just landing this as-is.
Keywords: checkin-needed
Autolander could not locate a review from a user within the suggested reviewer list. Either the patch author or the reviewer should be in the suggested reviewer list.
Okay, Autolander, I'll land it by hand...
Closed: 9 years ago
Resolution: --- → FIXED
Note that this fix is only for the part of the bug where the PDF viewer does not display anything.

The window management issue has been spun off into bug 1154838.
Comment on attachment 8592523 [details] [review]
[gaia] davidflanagan:bug1152841 > mozilla-b2g:master

[Approval Request Comment]
[Bug caused by] (feature/regressing bug #): not a regression; I don't think this has ever worked right

[User impact] if declined: users won't be able to view PDF files opened from 3rd party file manager apps.

[Testing completed]: locally

[Risk to taking this patch] (and alternatives if risky): not risky. This is a 2-line patch that just adds a fallback alternative in the case where the current code does not work. Given that the current code does not work, there is no way that this patch could make anything worse.

[String changes made]: none. When we have an unknown filename my patch purposely displays nothing instead of trying to add some kind of localized "unknown" string.
Attachment #8592523 - Flags: approval-gaia-v2.2?(bbajaj)
Attachment #8592523 - Flags: approval-gaia-v2.2?(bbajaj) → approval-gaia-v2.2+

Does something need to get upstreamed here?
Target Milestone: --- → 2.2 S10 (17apr)
As far as I can tell we've diverged from upstream and are no longer keeping the FirefoxOS pdf viewer app in sync with the offical pdf.js repo.  But I've emailed Brendan Dahl to ask if he's interested in this patch.
Though I suppose I should have just set needinfo for him here...
Flags: needinfo?(bdahl)
Per Comment 17 ("Note that this fix is only for the part of the bug where the PDF viewer does not display anything"), this bug has been successfully verified on latest Nightly Flame v2.2&3.0.
See attachment: verified_v2.2&3.0.mp4
Reproduce rate: 0/5

1.Download File manager app from Marketplace.
2.Copy PDF files to device's storage.
3.Open File manager,and select a PDF file to open (Or download a pdf file from browser,then open the file form notification bar).
**The PDF file shows its content normally.

Device: Flame 2.2 build(Pass)
Build ID               20150416162504
Gaia Revision          d50b8a3919a7b4d8d289f150d3b9bed704ebafa9
Gaia Date              2015-04-16 21:46:57
Gecko Revision
Gecko Version          37.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150416.195720
Firmware Date          Thu Apr 16 19:57:29 EDT 2015
Bootloader             L1TC000118D0

Device: Flame 3.0 build(Pass)
Build ID               20150416160206
Gaia Revision          3cd0a9facce26c2acc7be3755a17131a6358e33f
Gaia Date              2015-04-16 16:33:22
Gecko Revision
Gecko Version          40.0a1
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150416.191700
Firmware Date          Thu Apr 16 19:17:10 EDT 2015
Bootloader             L1TC000118D0
QA Whiteboard: [QAnalyst-Triage+] → [QAnalyst-Triage+][MGSEI-Triage+]
Just to reiterate what was mentioned in IRC. We're working on making pdf.js live on it's own in gaia and have it's own viewer and just provide a viewer API. We'll still try to sync up changes for the time being.

Flags: needinfo?(bdahl)
Depends on: 1162317
You need to log in before you can comment on or make changes to this bug.