Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(@capacitor/browser): Urls without https cause browser.open to crashes application #2036

Open
emelampianakis opened this issue Feb 20, 2024 · 6 comments

Comments

@emelampianakis
Copy link

emelampianakis commented Feb 20, 2024

Bug Report

Plugin(s)

@capacitor/browser ^5.2.0

Capacitor Version

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 5.7.0
  @capacitor/core: 5.7.0
  @capacitor/android: 5.7.0
  @capacitor/ios: 5.7.0

Installed Dependencies:

  @capacitor/cli: 5.7.0
  @capacitor/ios: 5.7.0
  @capacitor/core: 5.7.0
  @capacitor/android: 5.7.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

Android

Current Behavior

This happens when the app is opened from the push listener 'notificationActionPerformed'
In the notification data: urlToOpen = 'www.google.com'
When using .open({url: urlToOpen}) app crashes & stays unresponsive until app data are cleared

If the urlToOpen = 'https://www.google.com/' --> works as expected.

Expected Behavior

Open the url in the in app browser

Code Reproduction

 FirebaseMessaging.addListener('notificationActionPerformed', async (event) => {
        const urlToOpen = event.notification.data.urlToOpen;
        await Browser.open({
          url: urlToOpen,
        });
      });

Other Technical Details

Additional Context

The crashlytics report:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.capacitorjs.plugins.browser.BrowserControllerActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= pkg=com.android.chrome (has extras) }
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3897)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4043)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2437)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:211)
       at android.os.Looper.loop(Looper.java:300)
       at android.app.ActivityThread.main(ActivityThread.java:8294)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)

Caused by android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= pkg=com.android.chrome (has extras) }
       at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2220)
       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1859)
       at android.app.Activity.startActivityForResult(Activity.java:5624)
       at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:753)
       at android.app.Activity.startActivityForResult(Activity.java:5577)
       at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:734)
       at android.app.Activity.startActivity(Activity.java:6095)
       at androidx.core.content.ContextCompat$Api16Impl.startActivity(ContextCompat.java:978)
       at androidx.core.content.ContextCompat.startActivity(ContextCompat.java:318)
       at androidx.browser.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:483)
       at com.capacitorjs.plugins.browser.Browser.open(Browser.java:112)
       at com.capacitorjs.plugins.browser.BrowserControllerActivity.open(BrowserControllerActivity.java:43)
       at com.capacitorjs.plugins.browser.BrowserPlugin.lambda$open$0(BrowserPlugin.java:72)
       at com.capacitorjs.plugins.browser.BrowserPlugin.$r8$lambda$I9bLDRWh7vl57kOTAfjVKp5lWOU()
       at com.capacitorjs.plugins.browser.BrowserPlugin$$ExternalSyntheticLambda0.onControllerReady(:8)
       at com.capacitorjs.plugins.browser.BrowserControllerActivity.onCreate(BrowserControllerActivity.java:19)
       at android.app.Activity.performCreate(Activity.java:8538)
       at android.app.Activity.performCreate(Activity.java:8502)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1437)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3878)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4043)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2437)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:211)
       at android.os.Looper.loop(Looper.java:300)
       at android.app.ActivityThread.main(ActivityThread.java:8294)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)
@ionitron-bot ionitron-bot bot added the triage label Feb 20, 2024
@ionitron-bot ionitron-bot bot removed the triage label Feb 20, 2024
@IT-MikeS IT-MikeS changed the title @capacitor/browser: browser.open Crashes Application bug(@capacitor/browser): Urls without https cause browser.open to crashes application Feb 23, 2024
@IT-MikeS IT-MikeS added the type: bug A confirmed bug report label Feb 23, 2024
Copy link

ionitron-bot bot commented Feb 23, 2024

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@IT-MikeS
Copy link
Contributor

Updating the issue to reflect that this issue is about catching the error thrown off from not having a valid URL

@qliqdev
Copy link

qliqdev commented Apr 15, 2024

i have same crash log like

Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.app.example/com.capacitorjs.plugins.browser.BrowserControllerActivity}: android.content.ActivityNotFoundException: 

No Activity found to handle Intent { act=android.intent.action.VIEW dat=blob:https://com.app.example/3781e39f-7d87-4e85-b041-a8e20a4e9602 pkg=com.android.chrome (has extras) }

@SahanaDHegde
Copy link

SahanaDHegde commented Aug 27, 2024

We are using same @capacitor/browser ^5.2.0 version and having the same issue on adding the app to store. Can we have any update on this issue?

the crash report is below,

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3644)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3781)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:101)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:138)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2306)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at android.app.ActivityThread.main (ActivityThread.java:7918)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:936)

Caused by android.content.ActivityNotFoundException:
  at android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:2200)
  at android.app.Instrumentation.execStartActivity (Instrumentation.java:1839)
  at android.app.Activity.startActivityForResult (Activity.java:5507)
  at androidx.activity.ComponentActivity.startActivityForResult (ComponentActivity.java:753)
  at android.app.Activity.startActivityForResult (Activity.java:5465)
  at androidx.activity.ComponentActivity.startActivityForResult (ComponentActivity.java:734)
  at android.app.Activity.startActivity (Activity.java:5963)
  at androidx.core.content.ContextCompat$Api16Impl.startActivity (ContextCompat.java:978)
  at androidx.core.content.ContextCompat.startActivity (ContextCompat.java:318)
  at androidx.browser.customtabs.CustomTabsIntent.launchUrl (CustomTabsIntent.java:483)
  at com.capacitorjs.plugins.browser.Browser.open (Browser.java:112)
  at com.capacitorjs.plugins.browser.BrowserControllerActivity.open (BrowserControllerActivity.java:43)
  at com.capacitorjs.plugins.browser.BrowserPlugin.lambda$open$0 (BrowserPlugin.java:72)
  at com.capacitorjs.plugins.browser.BrowserPlugin.$r8$lambda$I9bLDRWh7vl57kOTAfjVKp5lWOU
  at com.capacitorjs.plugins.browser.BrowserPlugin$$ExternalSyntheticLambda0.onControllerReady
  at com.capacitorjs.plugins.browser.BrowserControllerActivity.onCreate (BrowserControllerActivity.java:19)
  at android.app.Activity.performCreate (Activity.java:8342)
  at android.app.Activity.performCreate (Activity.java:8321)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1417)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3625)

@Teo27
Copy link

Teo27 commented Sep 3, 2024

Had similar issue, but with valid links and also I found the cause so I will comment here.

I had the exact same stack trace but I was opening a valid link. Turns out the client never had a browser installed. The case was that said customer had 2 profiles -> personal and work. They installed the app on the work profile, had chrome installed on their personal profile but not on their work one. This cases the app to crash as soon as Browser.open is called. In retrospect this is obvious, but I sure spend hours debugging.

Not sure if this should somehow be handled from capacitors side, but I would at least recommend that it is documented somewhere, as all similar queries are about broken URLs and people might spend hours on this silly issue.

@LuanHimmlisch
Copy link

In my case, I wanted to redirect to a market:// URL. Please fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants