Skip to content

[WORKING IN PROGRESS] A lightweight performance monitor for webview in android, with kotlin.

License

Notifications You must be signed in to change notification settings

williamfzc/wvpm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WVPM

jitpack-badge

A lightweight performance monitor for webview in android, with kotlin.

TL;DR

This tool provided series of js scripts with their flags. You can easily use them on android side:

WvpmAPI.injectOnPageFinished(
    mWebview,
    WvpmJsFlag.FLAG_JS_PERF_TIMING,
    fun(resp: WvpmResponse) {
        Log.d(TAG, "get js return after page finished in activity: ${resp.data}")
    }
)
// or other events too, e.g. onPageStarted ...

and get its return value in callback function:

D/MainActivity: get js return after page finished in activity: {"connectEnd":1.608735286902e+12,"connectStart":1.608735286348e+12,"domComplete":1.608735311779e+12,"domContentLoadedEventEnd":1.608735295159e+12, ...

Something more complex? Register a fps monitor:

WvpmAPI.registerFpsMonitor(
    mWebview,
    fun(resp: WvpmResponse) {
        Log.w(TAG, "fps warning: ${resp.data}")
    },
    50
)

When your page's fps is lower than 50 (as you set), your callback will be evaluated:

W/MainActivity: fps warning: {"current":48,"threshold":50}

Less brain fuck. You can collect/save/upload them as you wish in callback functions.

Originally this tool was designed for working with apm systems. It should be extendable enough I think.

further goals (working in progress)

  • Injecting some callback functions to webview events (e.g. onPageFinished)
  • Built-in js scripts for easily getting something from js side (e.g. window.performance.xxx)
  • (Actually it can but I have no test) Working with ASM (dynamically applying this tool to all the webviews of your app)
  • Different kinds of webviews
  • Kotlin & Java usage

full example

Full demo here.

How to use these API:

installation

This repo uses jitpack.io.

root gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

app gradle:

dependencies {
    implementation 'com.github.williamfzc:wvpm:0.2.2'
}

Why not Jsbridge?

Jsbridge is good in developping your own app. WVPM aims at debugging/test usage.

BTW, it's nearly deprecated.

Inspired from ...

Thanks.

License

MIT

About

[WORKING IN PROGRESS] A lightweight performance monitor for webview in android, with kotlin.

Topics

Resources

License

Stars

Watchers

Forks