티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

Android webview slow

Android 웹뷰 속도가 느림

 문제 내용 

My android webviews are slow. This is on everything from phones to 3.0+ tablets with more than adequate specs

안드로이드 웹뷰가 느립니다. 이것은 적절한 사양 이상의 전화기에서 3.0 이상의 태블릿에 이르기까지 모든 것에 적용됩니다.

 

I know that webviews are supposed to be "limited" but I see web apps done with phone gap that must be using all sorts of CSS3 and JQuery sorcery, they run just fine and speedy

저는 웹뷰가 "제한적"이어야 한다는 것을 알고 있지만, 모든 종류의 CSS3와 JQuery sorcery을 사용해야 하는 다른 웹 앱을 봤지만, 그것들은 잘 작동하고 속도가 빠릅니다.

 

so I'm missing something, is there some kind of myWebview.SPEEDHACK(1) that I can use to speed things up?

그래서 제가 뭔가를 놓치고 있는 것 같습니다. 속도를 높이는 데 사용할 수 있는 일종의 myWebview.SPEEDHACK(1)이 있습니까?

 

also, sometimes the contents of my webview just simply don't load, instead of slowly loading, it just wont load. The asset I am testing with is stored locally, no errors.

또한 때때로 내 webview의 내용이 단순히 로드되지 않고 천천히 로드되는 대신 로드되지 않습니다. 테스트 중인 asset은 오류 없이 로컬에 저장됩니다.

 

 

 

 높은 점수를 받은 Solution 

It depends on the web application being loaded. Try some of the approaches below:

로드되는 웹 응용 프로그램에 따라 다릅니다. 아래의 몇 가지 방법을 시도해 보십시오.

 

Set higher render priority (deprecated from API 18+):

더 높은 렌더 우선 순위 설정(API 18+에서 지원 중단됨):
webview.getSettings().setRenderPriority(RenderPriority.HIGH);

 

Enable/disable hardware acceleration:

하드웨어 가속 사용/사용 안 함:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // chromium, enable hardware acceleration
    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
    // older android version, disable hardware acceleration
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

 

Disable the cache (if you have problems with your content):

캐시 사용 안 함(콘텐츠에 문제가 있는 경우):
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

 

 

 가장 최근 달린 Solution 

None of those answers was not helpful for me.

그 대답들 중 어느 것도 나에게 도움이 되지 않았다.

 

Finally I have found reason and solution. The reason was a lot of CSS3 filters (filter, -webkit-filter).

마침내 나는 이유와 해결책을 찾았다. 그 이유는 많은 CSS3 필터(필터, -webkit-filter)였다.

 

Solution

해결책

 

I have added detection of WebView in web page script in order to add class "lowquality" to HTML body. BTW. You can easily track WebView by setting user-agent in WebView settings. Then I created new CSS rule

HTML 본문에 "lowquality" 클래스를 추가하기 위해 웹 페이지 스크립트에 WebView 감지 기능을 추가했습니다. 그건 거렇고, WebView 설정에서 user-agent를 설정하여 WebView를 쉽게 추적할 수 있습니다. 그런 다음 새 CSS 규칙을 만들었습니다.

 

body.lowquality * { filter: none !important; }

 

 

출처 : https://stackoverflow.com/questions/7422427/android-webview-slow

반응형
댓글
공지사항
최근에 올라온 글