Closed Bug 1253399 Opened 8 years ago Closed 8 years ago

Crash when connecting with DevTools over WiFi and barcode scanner not installed

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(firefox48 fix-optional, firefox49 fix-optional, fennec48+, firefox50 fixed)

RESOLVED FIXED
Firefox 50
Tracking Status
firefox48 --- fix-optional
firefox49 --- fix-optional
fennec 48+ ---
firefox50 --- fixed

People

(Reporter: jryans, Assigned: jryans)

References

(Blocks 1 open bug)

Details

(Keywords: crash)

Attachments

(1 file, 1 obsolete file)

Had a report over IRC from dx that Fennec can crash if you try to connect with DevTools via WiFi and the barcode app is not installed.

I believe they were testing with 44 at the time.
Status: UNCONFIRMED → NEW
tracking-fennec: --- → ?
Ever confirmed: true
OS: Unspecified → Android
Hardware: Unspecified → All
The WiFi debugging option on the device is disabled if the barcode scanner app is not installed.  However, that does not protect against removing the scanner app later on.

So, possible STR:

1. Install Barcode Scanner app
2. Enable WiFi debugging in Fennec
3. Uninstall Barcode Scanner app
4. Connect to device via WiFi
5. Press Scan on device auth prompt

This will crash Fennec since the scanner app is no longer there.  So, we should catch that case and probably provide some error message.
I have a fix for this locally, but I am at a work week, and it is hard to reproduce the issue on this WiFi network.  Will continue when I get back home next week.
Assignee: nobody → jryans
Status: NEW → ASSIGNED
tracking-fennec: ? → 48+
Have you been able to make any progress on this bug?
Flags: needinfo?(jryans)
Attached patch WIP: Attempt to stop crashing (obsolete) — Splinter Review
(In reply to :Margaret Leibovic from comment #4)
> Have you been able to make any progress on this bug?

I think I had some build trouble at the time and then it fell off my radar.

I gave it another try just now, and I've managed to prevent the crash by catching the ActivityNotFoundException, but then Fennec seems to hang after that.  I'm not sure why that would happen or how to debug it...  I don't have a rooted phone at the moment, so a lot of the debug tools don't work for me.

Do you know why it would hang or how to investigate it?  Is there something I needed to do with the Messaging API when it fails?
Flags: needinfo?(jryans)
Attachment #8762176 - Flags: feedback?(margaret.leibovic)
(In reply to J. Ryan Stinnett [:jryans] (use ni?) (at work week until June 21) from comment #5)
> Created attachment 8762176 [details] [diff] [review]
> WIP: Attempt to stop crashing
> 
> (In reply to :Margaret Leibovic from comment #4)
> > Have you been able to make any progress on this bug?
> 
> I think I had some build trouble at the time and then it fell off my radar.
> 
> I gave it another try just now, and I've managed to prevent the crash by
> catching the ActivityNotFoundException, but then Fennec seems to hang after
> that.  I'm not sure why that would happen or how to debug it...  I don't
> have a rooted phone at the moment, so a lot of the debug tools don't work
> for me.

You shouldn't need a rooted phone to debug an app crash. Are you using Android Studio? I believe the Java debugger should Just Work if you have that set up.

> Do you know why it would hang or how to investigate it?  Is there something
> I needed to do with the Messaging API when it fails?

I'm not sure why Fennec would hang. Are there any errors in the log? I don't think this should have to do with the Messaging API.

Maybe Sebastian has some ideas here?
Flags: needinfo?(s.kaspari)
I can reproduce this with the STR and applied the patch.

It seems like the only problem is the sendError() call from the catch block: onActivityResult() is called and the callback is executed - after that we catch the exception and try to call the callback again (exception / crash).

It's weird that onActivityResult() gets called even though we were not able to start an activity. According to Stackoverflow our launchMode might be triggering this:
http://stackoverflow.com/questions/3354955/onactivityresult-called-prematurely

You could:
- Not call the callback yourself and rely on onActivityResult. But this is a bit scary and we need to make sure that this calls onError() and not onSuccess() in this case.
- OR: Query the PackageManager upfront to see if there's an activity that can handle the Intent. If there's none then do not do anything and just invoke onError().
Flags: needinfo?(s.kaspari)
Attachment #8762176 - Flags: feedback?(margaret.leibovic)
Comment on attachment 8763982 [details]
Bug 1253399 - Avoid crashes by checking for QR scanner app.

https://reviewboard.mozilla.org/r/60056/#review57226

::: mobile/android/base/java/org/mozilla/gecko/DevToolsAuthHelper.java:51
(Diff revision 1)
> +        } catch (final SecurityException e) {
> +            Log.w(LOGTAG, "Forbidden to launch activity.", e);
> +            callback.sendError("Forbidden to launch activity.");
> +        }

Did you test this specific case? I wonder if this will result in the same error because the callback is executed twice (I'm not sure if onActivityResult() will be called here).
Attachment #8763982 - Flags: review?(s.kaspari) → review+
https://reviewboard.mozilla.org/r/60056/#review57226

> Did you test this specific case? I wonder if this will result in the same error because the callback is executed twice (I'm not sure if onActivityResult() will be called here).

No, I was just cargo-culting from `ActivityHandlerHelper.startIntentAndCatch`.  Looks like Android docs say it shouldn't throw a SecurityException anyway, and I don't have a test case, so I'll just remove this part for now.
Comment on attachment 8763982 [details]
Bug 1253399 - Avoid crashes by checking for QR scanner app.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/60056/diff/1-2/
Marking 48 and 49 fix-optional, up to Android team if they'd like to uplift.  This is not a new issue, it's been around for since WiFi debugging originally appeared.
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/fx-team/rev/7e6896f7bed5
Avoid crashes by checking for QR scanner app. r=sebastian
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/7e6896f7bed5
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 50
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: