Closed
Bug 1224295
Opened 9 years ago
Closed 9 years ago
crash in android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ContextImpl.startActivity(ContextImpl.java)
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(firefox45 fixed)
RESOLVED
FIXED
Firefox 45
Tracking | Status | |
---|---|---|
firefox45 | --- | fixed |
People
(Reporter: dholbert, Assigned: jchen)
References
Details
(Keywords: crash, regression)
Crash Data
Attachments
(3 files, 1 obsolete file)
236.96 KB,
image/png
|
Details | |
1.32 KB,
patch
|
Details | Diff | Splinter Review | |
2.51 KB,
patch
|
jchen
:
review+
|
Details | Diff | Splinter Review |
This bug was filed from the Socorro interface and is report bp-12e89aa1-acbf-4363-bcb6-49d2b2151112. ============================================================= STR: 1. Download any file in Nightly on Android (e.g. an .apk or a .pdf file) 2. Menu | Tools | Downloads 3. Tap the entry for your download. ACTUAL RESULTS: - After ~1 second, Mozilla's crash report dialog appears. - (Downloaded file is not opened.) Sample crash reports: bp-12e89aa1-acbf-4363-bcb6-49d2b2151112 bp-c9737eb7-185f-4cd5-93b3-d809f2151112 bp-9f6620e0-0737-4f69-9a2e-440c92151112 bp-63a333a0-bc31-4f9b-9c7b-3ce492151112 I can reproduce in latest Nightly on Android. I've tested with two different files: - The "Developer Preview" .apk, linked from https://hacks.mozilla.org/2015/11/firefox-os-2-5-developer-preview-an-experimental-android-app/ Direct link: https://d2yw7jilxa8093.cloudfront.net/B2GDroid-mozilla-central-nightly-latest.apk - This PDF file: https://interledger.org/interledger.pdf I assume this repro's with any downloaded file; I'm just including these examples for reference.
Reporter | ||
Comment 1•9 years ago
|
||
I can't reproduce in Aurora on Android, FWIW. So this is a regression. (Likely a regression in the last week, since I've got a file that I know I downloaded & opened successfully last Friday.)
Reporter | ||
Updated•9 years ago
|
Keywords: regression
Reporter | ||
Comment 2•9 years ago
|
||
If it matters: I'm using a OnePlus One phone, on CyanogenMod 12.1 (which is basically Android 5.1.1). I'm using the latest Nightly -- my build ID (from the crash report) is 20151112030238.
Comment 3•9 years ago
|
||
This could be outfall from the GeckoAppShell refactoring? (bug 1219016) > android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? > at android.app.ContextImpl.startActivity(ContextImpl.java:1269) > at android.app.ContextImpl.startActivity(ContextImpl.java:1256) > at android.content.ContextWrapper.startActivity(ContextWrapper.java:329) > at org.mozilla.gecko.ActivityHandlerHelper.startIntentAndCatch(ActivityHandlerHelper.java:37) > at org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(ExternalIntentDuringPrivateBrowsingPromptFragment.java:66) > at org.mozilla.gecko.GeckoAppShell.openUriExternal(GeckoAppShell.java:1083) > at org.mozilla.gecko.GeckoAppShell.openUriExternal(GeckoAppShell.java:1027) > at org.mozilla.gecko.mozglue.GeckoLoader.nativeRun(Native Method) > at org.mozilla.gecko.GeckoThread.run(GeckoThread.java:437) Also NI-ing Mike because this call goes through ExternalIntentDuringPrivateBrowsingPromptFragment.
Flags: needinfo?(nchen)
Flags: needinfo?(michael.l.comella)
Like Sebastian said, this looks like fallout from bug 1219016. We get the context to open the new Activity in GeckoAppShell.openUriExternal from GeckoAppShell.getApplicationContext. The context we were using before was the Activity context but now it's the application context. I don't think it'd change the expected behavior if we just added the NEW_TASK flag (does back still work correctly?) but I haven't played around with this enough to know for sure. However, I'm not sure if this is the best solution – let's see if Jim has any opinions.
Blocks: 1219016
Flags: needinfo?(michael.l.comella)
Comment 5•9 years ago
|
||
(In reply to Michael Comella (:mcomella) from comment #4) > I don't think it'd change the expected behavior if we just added the > NEW_TASK flag (does back still work correctly?) but I haven't played around > with this enough to know for sure. However, I'm not sure if this is the best > solution – let's see if Jim has any opinions. Based on hazy recollection, NEW_TASK won't work the same -- after all, it tries to create a new task to host the activity, but we have a singleTask application, so instead it will… who knows? Worst case things will go really crazy. Most likely the existing browser activity stack will be truncated and reparented to the new task, losing your previous task or something else. Best case the task stack navigation will take over, but that still probably won't be exactly the same. Testing back stack handling is really thorny: you need to test stuff like opening from notifications while mid-way through composing an email from a share, FxA setup, in-app navigation for Twitter links, using the app switcher… all the stuff that normally futzes with tasks and activities. The fix least likely to cause problems is to… use the correct activity context. We might consider using a weak reference in GeckoAppShell to the current browser activity, only falling back to the application context with NEW_TASK if there's no current activity context.
I can reproduce this more simply, with less involvement of the Browser. 1. Download a File such as a .PDF . 2. After downloading the Android OS will have a Notification, without disturbing the Browser pull down your Notifications, click on the Notification for the downloaded File. Crash, everytime. Since it seems to not involve doing something IN the Browser could it be that the Browser has done something outside whete it was supposed to access (the Library allocated Memory without checking it out from the OS). I notice that I get similar problems typing Comments on YouTube, once the Comment gets to a certain length the Browser mysteriously crashes. BPs: bp-7e62bfe7-6c6d-42e9-82f4-971f62151113 bp-6425eea7-dfb2-4bfb-bcc5-b43612151112 bp-4ceb92e8-9b37-41de-a9e1-6dc3a2151022 bp-f148b5f8-3687-4eed-ad25-fda212151109 bp-4dddfbab-a1f4-49e3-a1a8-4e9b62151109
Comment 7•9 years ago
|
||
If this is opening an external application (just assuming from 'openUriExternal') then adding NEW_TASK actually makes a lot of sense. Without it the opened activity of the other app becomes part of our task and you can't switch back and forth between the two (See attached image).
Comment 8•9 years ago
|
||
I see this on Nexus 5 running Android 6.0 with security patch level of November 1, 2015 when tapping the Android robot icon in the URL bar when the current page is a YouTube video page. (I have the UA string set to Firefox OS UA string in order for sites like Twitter not to suggest that I install an app, so the YouTube video page I get is customized for Firefox OS, but those pages don't work in Fennec, which is why I want to open YouTube videos in the native app.)
Happening anytime you try to open a video in an external application like vlc Or going to http://www.flipkart.com where it tries to open PlayStore to get the app. https://crash-stats.mozilla.com/report/index/eb51bbe0-dec6-4706-8fec-fde702151114
Comment 10•9 years ago
|
||
This is a partial backout of bug 1219016, and appears sufficient to fix the issue. I am not, however, taking this bug as I really am just guessing at a fix here and have no real understanding of the ramififications of making this change.
Comment 12•9 years ago
|
||
(In reply to Sebastian Kaspari (:sebastian) from comment #7) > Created attachment 8687100 [details] > opening_pdf_external.png > > If this is opening an external application (just assuming from > 'openUriExternal') then adding NEW_TASK actually makes a lot of sense. > Without it the opened activity of the other app becomes part of our task and > you can't switch back and forth between the two (See attached image). OK. But wouldn't that type of change require ux approval?
Assignee | ||
Comment 13•9 years ago
|
||
Anthony, what do you think of the change in comment 7 (change from top behavior to bottom behavior)? FWIW, Chrome implements the behavior at the bottom.
Flags: needinfo?(nchen) → needinfo?(alam)
Comment 14•9 years ago
|
||
NEW_TASK behavior seems OK. I'd be fine with that change.
Assignee | ||
Comment 15•9 years ago
|
||
r+ from IRC. This patch adds FLAG_ACTIVITY_NEW_TASK to two places where we start activities from app contexts. In GeckoAppShell, the flag replaces the FLAG_ACTIVITY_CLEAR_TOP flag from before.
Attachment #8688065 -
Flags: review+
Comment 17•9 years ago
|
||
(In reply to Sebastian Kaspari (:sebastian) from comment #7) > Created attachment 8687100 [details] > opening_pdf_external.png > > If this is opening an external application (just assuming from > 'openUriExternal') then adding NEW_TASK actually makes a lot of sense. > Without it the opened activity of the other app becomes part of our task and > you can't switch back and forth between the two (See attached image). (In reply to Jim Chen [:jchen] [:darchons] from comment #13) > Anthony, what do you think of the change in comment 7 (change from top > behavior to bottom behavior)? FWIW, Chrome implements the behavior at the > bottom. (In reply to Mark Finkle (:mfinkle) from comment #14) > NEW_TASK behavior seems OK. I'd be fine with that change. Me three! This makes sense. Thanks for the NI Jim, appreciate the context!
Flags: needinfo?(alam)
Comment 18•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/809df5373176
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox45:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Comment 20•8 years ago
|
||
¡Hola Jim! Is this really fixed? https://crash-stats.mozilla.com/report/list?product=FennecAndroid&range_unit=days&range_value=28&signature=android.util.AndroidRuntimeException%3A+Calling+startActivity%28%29+from+outside+of+an+Activity++context+requires+the+FLAG_ACTIVITY_NEW_TASK+flag.+Is+this+really+what+you+want%3F+at+android.app.ContextImpl.startActivity%28ContextImpl.java%29#tab-reports shows 171 crashes in the past month. ¡Gracias!
Flags: needinfo?(nchen)
Assignee | ||
Comment 21•8 years ago
|
||
Thanks! Looks like I missed one spot. Going to open a new bug.
Flags: needinfo?(nchen)
Assignee | ||
Updated•8 years ago
|
Updated•8 years ago
|
Assignee: nobody → nchen
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•