Skip to content

[Android WebView] can't load url #5211

Closed
@terrysahaidak

Description

@terrysahaidak

I'm trying to load this URL https://gitter.im/login in my web view component, but it doesn't loads.

It just displays this:

I've tried to load it in a default android browser and it had loaded successfully.

Some code:

        <View style={{flex: 1}}>
          <WebView
            ref='webview'
            style={{height: 400}}
            url={'https://gitter.im/login/'}
            javaScriptEnabled={true}
            domStorageEnabled={true}
            onNavigationStateChange={this.onNavigationStateChange}
          />
        </View>

I'm on 0.18.0-rc.

Also tried other URLs, and it works perfectly works well only if there is no js. It seems like a bug with enabling javascript.

Also tried to use javaScriptEnabledAndroid, but nothing was change.

Activity

changed the title [-][Android WebView] can't load ulr[/-] [+][Android WebView] can't load url[/+] on Jan 9, 2016
facebook-github-bot

facebook-github-bot commented on Jan 9, 2016

@facebook-github-bot
Contributor

Hey terrysahaidak, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!
satya164

satya164 commented on Jan 10, 2016

@satya164
Contributor

Do other pages load? Can you open chrome://inspect and see if you can debug the issue?

terrysahaidak

terrysahaidak commented on Jan 10, 2016

@terrysahaidak
Author

@satya164 yup, it does. But I still cant load gitter.im site. It loads welcome screen, then I'm login through GitHub and redirecting back, but it doesn't loads. And when I'm trying to visit it again with my cookies, it won't load.
I think it isn't the problem with Gitter because there is an app for android called Developer Talks where the user should login through webview.

I'll try to inspect it later and let you know.

And sorry for my English :)

terrysahaidak

terrysahaidak commented on Jan 11, 2016

@terrysahaidak
Author

@satya164 I've debugged the issue and I assume that it doesn't render the HTML.

I can also submit the form with this code:

var submit = document.getElementById('allow')
submit.click()
terrysahaidak

terrysahaidak commented on Jan 11, 2016

@terrysahaidak
Author

Also tried to load this URL with this app (github) and it works.

tomauty

tomauty commented on Jan 11, 2016

@tomauty

No console errors?

terrysahaidak

terrysahaidak commented on Jan 11, 2016

@terrysahaidak
Author

@tomauty no. BTW I'm running it in 5.1.1 on my sgs4 i9505.

It seems like a magic 😄

terrysahaidak

terrysahaidak commented on Jan 28, 2016

@terrysahaidak
Author

Just tried it with 0.19.0-rc and got the same result. 😟

terrysahaidak

terrysahaidak commented on Jan 31, 2016

@terrysahaidak
Author

Just got it working by deleting some css code. But still can't realize why it does not work like native webview?

I've disabled height: 100% html tag's rule (the best result i've got because of that). And got it:

kevinejohn

kevinejohn commented on Feb 8, 2016

@kevinejohn
Contributor

+1 I'm running into the same issue with certain websites.

kevinejohn

kevinejohn commented on Feb 8, 2016

@kevinejohn
Contributor

I figured it out. If you make the WebView as the parent instead of being nested in the View it loads the websites fine. Not exactly sure why.

terrysahaidak

terrysahaidak commented on Feb 8, 2016

@terrysahaidak
Author

@kevinejohn now it nested only inside some containers -- Navigator and Root

I've fixed that by injection this js code:

const jsForInjection = `
  var el = document.getElementsByTagName('body')[0];
  el.style.height = '${Dimensions.get('window').height}px';
`

27 remaining items

spicylobster

spicylobster commented on Jun 16, 2016

@spicylobster

@ncnlinh You are quite right. I finally solved this problem using your method. some other reference https://bugzilla.xamarin.com/show_bug.cgi?id=25932

ncnlinh

ncnlinh commented on Jun 16, 2016

@ncnlinh

@spicylobster I was using a custom webview component for a while now. I think Webview itself in Android is very customizable, and one may want to add JavascriptInterface, override URL loading, and change other settings. So I feel that it's hard to ask RN to accommodate everything in one component...

ghost closed this as completedin 1bb1385on Jul 27, 2016
added a commit that references this issue on Aug 3, 2016
af332fc
tyao1

tyao1 commented on Aug 11, 2016

@tyao1
Contributor

I've spent several hours and managed to make all WebView pages to display on Android.
I'm using version 0.30.

  1. Make sure the key of props passed to source is uri, not url. I was using url on iOS, but it only accepts uri as the key on Android
  2. Set startInLoadingState to false. Whenever I set startInLoadingState to true, the page just doesn't load.
  3. Inject JS and set html or body's height directly to your webview's height (I'm not sure if it is fixed in the latest release)

Hope it helps!

fnd009

fnd009 commented on Aug 24, 2016

@fnd009

Hi, I had this problem too but when I specify the width in the style then the page is now displayed/rendered.

const styles = StyleSheet.create({
  webView: {
    backgroundColor: 'rgba(255,255,255,0.8)',
    height: 350,
    width: 350 // <-- Required somehow
  }
});
added a commit that references this issue on Aug 25, 2016
7ad898c
nfabian13

nfabian13 commented on Aug 31, 2016

@nfabian13

@fnd009 That solved my issue. Thanks

matthewvincent

matthewvincent commented on Sep 29, 2016

@matthewvincent

@fnd009 this solved my issue, no clue why but thanks!

tioback

tioback commented on Oct 22, 2016

@tioback

I keep randomly getting a blank page. I noticed the following in logcat:

10-20 16:02:50.717  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.717  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.723  1096  1096 I art     : Alloc sticky concurrent mark sweep GC freed 4236(176KB) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 414us total 5.694ms
10-20 16:02:50.723  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.750  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.750  1096  1096 I art     : Alloc partial concurrent mark sweep GC freed 602(20KB) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 522us total 26.456ms
10-20 16:02:50.750  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.775  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.775  1096  1096 I art     : Alloc concurrent mark sweep GC freed 19(704B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 490us total 24.850ms
10-20 16:02:50.775  1096  1096 I art     : Forcing collection of SoftReferences for 50MB allocation
10-20 16:02:50.775  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.798  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.798  1096  1096 I art     : Alloc concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 510us total 23.221ms
10-20 16:02:50.798  1096  1096 W art     : Throwing OutOfMemoryError "Failed to allocate a 53360652 byte allocation with 7620352 free bytes and 7MB until OOM"
10-20 16:02:50.798  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.798  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.802  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.825  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.825  1096  1096 I art     : Alloc partial concurrent mark sweep GC freed 4(128B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 509us total 23.039ms
10-20 16:02:50.825  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.850  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.850  1096  1096 I art     : Alloc concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 547us total 25.362ms
10-20 16:02:50.850  1096  1096 I art     : Forcing collection of SoftReferences for 50MB allocation
10-20 16:02:50.850  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.876  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.876  1096  1096 I art     : Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 1.177ms total 25.366ms
10-20 16:02:50.876  1096  1096 W art     : Throwing OutOfMemoryError "Failed to allocate a 53360652 byte allocation with 7620352 free bytes and 7MB until OOM"
10-20 16:02:50.876  1096  1096 W JavaBrowserViewRendererHelper: Error allocating bitmap
10-20 16:02:50.876  1096  1096 E chromium: [ERROR:java_browser_view_renderer_helper.cc(133)] Error unlocking java bitmap pixels.
10-20 16:02:50.876  1096  1096 W art     : Attempt to remove non-JNI local reference, dumping thread
10-20 16:02:50.878  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.878  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.883  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.905  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.905  1096  1096 I art     : Alloc partial concurrent mark sweep GC freed 6(192B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 506us total 22.271ms
10-20 16:02:50.905  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.930  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.930  1096  1096 I art     : Alloc concurrent mark sweep GC freed 1(32B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 521us total 24.907ms
10-20 16:02:50.930  1096  1096 I art     : Forcing collection of SoftReferences for 50MB allocation
10-20 16:02:50.930  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.954  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.954  1096  1096 I art     : Alloc concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 500us total 23.262ms
10-20 16:02:50.954  1096  1096 W art     : Throwing OutOfMemoryError "Failed to allocate a 53360652 byte allocation with 7620352 free bytes and 7MB until OOM"
10-20 16:02:50.954  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.954  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.957  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:50.980  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:50.980  1096  1096 I art     : Alloc partial concurrent mark sweep GC freed 5(144B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 501us total 23.284ms
10-20 16:02:50.980  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:51.003  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:51.003  1096  1096 I art     : Alloc concurrent mark sweep GC freed 4(144B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 498us total 23.138ms
10-20 16:02:51.003  1096  1096 I art     : Forcing collection of SoftReferences for 50MB allocation
10-20 16:02:51.003  1096  1096 I art     : Starting a blocking GC Alloc
10-20 16:02:51.028  1096  1096 I art     : Clamp target GC heap from 104MB to 96MB
10-20 16:02:51.028  1096  1096 I art     : Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 7% free, 88MB/96MB, paused 503us total 24.240ms
10-20 16:02:51.028  1096  1096 W art     : Throwing OutOfMemoryError "Failed to allocate a 53360652 byte allocation with 7620352 free bytes and 7MB until OOM"
10-20 16:02:51.028  1096  1096 W JavaBrowserViewRendererHelper: Error allocating bitmap
10-20 16:02:51.028  1096  1096 E chromium: [ERROR:java_browser_view_renderer_helper.cc(133)] Error unlocking java bitmap pixels.
10-20 16:02:51.028  1096  1096 W art     : Attempt to remove non-JNI local reference, dumping thread
locked as resolved and limited conversation to collaborators on Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @maraujop@kevinejohn@tomauty@satya164@geirman

      Issue actions

        [Android WebView] can't load url · Issue #5211 · facebook/react-native