Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/williamfzc/wvpm
[WORKING IN PROGRESS] A lightweight performance monitor for webview in android, with kotlin.
https://github.com/williamfzc/wvpm
android jsbridge kotlin monitor performance webview
Last synced: about 1 month ago
JSON representation
[WORKING IN PROGRESS] A lightweight performance monitor for webview in android, with kotlin.
- Host: GitHub
- URL: https://github.com/williamfzc/wvpm
- Owner: williamfzc
- License: mit
- Created: 2020-12-18T14:33:43.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-05T12:09:28.000Z (about 4 years ago)
- Last Synced: 2024-11-09T08:46:59.215Z (3 months ago)
- Topics: android, jsbridge, kotlin, monitor, performance, webview
- Language: Kotlin
- Homepage:
- Size: 242 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WVPM
![jitpack-badge](https://jitpack.io/v/williamfzc/wvpm.svg?style=flat-square)
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:
```kotlin
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:
```javascript
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:
```kotlin
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:
```text
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)
- [x] Injecting some callback functions to webview events (e.g. onPageFinished)
- [x] 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)
- [x] Different kinds of webviews
- [x] Kotlin & Java usage## full example
Full [demo](./demo) here.
How to use these API:
- kotlin: [MainActivity.kt](./demo/app/src/main/java/com/github/williamfzc/webvpm_demo/MainActivity.kt)
- java: [JavaActivity.java](./demo/app/src/main/java/com/github/williamfzc/webvpm_demo/JavaActivity.java)## installation
This repo uses [jitpack.io](jitpack.io).
root gradle:
```bash
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```app gradle:
```bash
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 ...
- [DoraemonKit](https://github.com/didi/DoraemonKit)
- [JsBridge](https://github.com/lzyzsd/JsBridge)
- ...Thanks.
## License
[MIT](LICENSE)