a914-gowtham / android-video-trimmer

Helps to trim local videos with compress option on Android applications using Exoplayer 2 and FFmpeg.
Other
380 stars 117 forks source link

ANR Occurs when editing a large video #24

Closed MujammilAhamed closed 4 years ago

MujammilAhamed commented 4 years ago

ANR Occurs in Trimming a larger video file size of more than 100 Mb Screenshot_20201125-114547

Device - Google Pixel 2 OS - Android 11

E/ActivityManager: ANR in x.x.x (x.x.x/com.gowtham.library.ui.ActVideoTrimmer) Reason: Input dispatching timed out (61e2e37 x.x.x/com.gowtham.library.ui.ActVideoTrimmer (server) is not responding. Waited 5001ms for FocusEvent(hasFocus=true)) Parent: x.x.x/com.gowtham.library.ui.ActVideoTrimmer

a914-gowtham commented 4 years ago

Can you share the full error log

MujammilAhamed commented 4 years ago

Here's the full logcat of the ANR occurred from the sample App

2020-11-23 18:14:38.537 1350-23366/? E/ActivityManager: ANR in com.gowtham.videotrimmer (com.gowtham.videotrimmer/com.gowtham.library.ui.ActVideoTrimmer)
    PID: 22803
    Reason: Input dispatching timed out (f21cbaf com.gowtham.videotrimmer/com.gowtham.library.ui.ActVideoTrimmer (server) is not responding. Waited 5001ms for MotionEvent)
    Parent: com.gowtham.videotrimmer/com.gowtham.library.ui.ActVideoTrimmer
    Load: 5.54 / 4.63 / 4.56
    CPU usage from 31501ms to 0ms ago (2020-11-23 18:14:03.654 to 2020-11-23 18:14:35.155):
      95% 19268/com.ezidox.contributor: 94% user + 0.4% kernel / faults: 10 minor
      31% 1350/system_server: 15% user + 15% kernel / faults: 71680 minor 14711 major
      0.1% 1153/media.swcodec: 0% user + 0% kernel / faults: 293994 minor 3 major
      12% 24546/com.google.android.googlequicksearchbox:search: 9.6% user + 2.5% kernel / faults: 72277 minor 13354 major
      10% 666/surfaceflinger: 8.4% user + 1.9% kernel / faults: 1097 minor 5 major
      6.1% 19435/x.x.x: 5.4% user + 0.7% kernel / faults: 2048 minor 421 major
      0% 1148/media.codec: 0% user + 0% kernel / faults: 19346 minor 4 major
      5.7% 1842/com.android.systemui: 4.2% user + 1.5% kernel / faults: 11958 minor 5361 major
      0% 1140/mediaserver: 0% user + 0% kernel / faults: 35902 minor 6 major
      4.5% 2560/com.google.android.gms.persistent: 3% user + 1.5% kernel / faults: 14648 minor 5588 major
      4% 105/system: 0% user + 4% kernel
      3.9% 2980/com.google.android.gms: 2.6% user + 1.3% kernel / faults: 13433 minor 7900 major
      3.9% 150/kswapd0: 0% user + 3.9% kernel
      0% 875/android.hardware.audio.service: 0% user + 0% kernel / faults: 460 minor 41 major
      0.1% 965/audioserver: 0.1% user + 0% kernel / faults: 813 minor 12 major
      2.4% 672/android.hardware.graphics.composer@2.1-service: 0.9% user + 1.4% kernel / faults: 216 minor
      2.4% 3436/com.google.android.providers.media.module: 0.6% user + 1.8% kernel / faults: 20110 minor 2609 major
      2.1% 22383/mdss_fb0: 0% user + 2.1% kernel
      1.8% 27389/com.lenovo.anyshare.gps: 1.2% user + 0.6% kernel / faults: 8040 minor 5010 major
      1.3% 1025/traced_probes: 1% user + 0.2% kernel / faults: 399 minor
      1.1% 16860/adbd: 0.3% user + 0.7% kernel / faults: 499 minor
      0% 646/irq/760-synapti: 0% user + 0% kernel
      0.9% 622/logd: 0.4% user + 0.5% kernel / faults: 511 minor
      0.9% 2124/com.google.android.apps.nexuslauncher: 0.6% user + 0.3% kernel / faults: 4075 minor 3146 major
      0.6% 22425/kworker/u16:12: 0% user + 0.6% kernel
      0.6% 902/android.hardware.sensors@1.0-service: 0.1% user + 0.4% kernel / faults: 173 minor
      0.6% 22061/kworker/0:4: 0% user + 0.6% kernel
      0.6% 22357/kworker/0:1: 0% user + 0.6% kernel
      0.5% 3382/com.google.android.as: 0.4% user + 0.1% kernel / faults: 3490 minor 2254 major
      0% 1187/android.hardware.biometrics.fingerprint@2.1-service.fpc: 0% user + 0% kernel / faults: 69 minor 2 major
      0.5% 22154/kworker/u16:0: 0% user + 0.5% kernel
      0.5% 21346/kworker/u16:5: 0% user + 0.5% kernel
      0.4% 87/smem_native_rpm: 0% user + 0.4% kernel
      0.4% 915/android.hardware.wifi@1.0-service: 0.3% user + 0.1% kernel / faults: 675 minor 20 major
      0.4% 22409/kworker/u16:2: 0% user + 0.4% kernel
      0.4% 623/lmkd: 0% user + 0.3% kernel / faults: 32 minor
      0.3% 674/android.hardware.graphics.allocator@2.0-service: 0% user + 0.3% kernel / faults: 180 minor
      0.3% 3456/com.google.process.gservices: 0.2% user + 0.1% kernel / faults: 1119 minor 583 major
      0.3% 7/rcu_preempt: 0% user + 0.3% kernel
      0.3% 2254/com.android.phone: 0.2% user + 0% kernel / faults: 1583 minor 543 major
      0.3% 17398/logcat: 0.1% user + 0.2% kernel / faults: 31 minor
      0.3% 17450/kworker/u17:2: 0% user + 0.3% kernel
      0% 865/zygote64: 0% user + 0% kernel / faults: 2019 minor
      0.2% 290/kgsl_worker_thr: 0% user + 0.2% kernel
      0.2% 725/jbd2/dm-2-8: 0% user + 0.2% kernel
      0.2% 10/rcuop/0: 0% user + 0.2% kernel
      0.2% 28/rcuop/2: 0% user + 0.2% kernel
      0% 83/smem_native_lpa: 0% user + 0% kernel
      0% 84/lpass_smem_glin: 0% user + 0% kernel
      0.2% 624/servicemanager: 0.2% user + 0% kernel / faults: 136 minor
2020-11-23 18:14:38.537 1350-23366/? E/ActivityManager:   0% 629/sugov:4: 0% user + 0% kernel
      0.2% 864/statsd: 0% user + 0.1% kernel / faults: 155 minor
      0.2% 3804/com.google.android.inputmethod.latin: 0% user + 0.1% kernel / faults: 1232 minor 150 major
      0% 360/rot_commitq_0_0: 0% user + 0% kernel
      0% 21632/com.google.android.apps.messaging: 0% user + 0% kernel / faults: 298 minor 1 major
      0.2% 22411/kworker/u16:10: 0% user + 0.2% kernel
      0.2% 22424/kworker/u16:11: 0% user + 0.2% kernel
      0.1% 60/rcuop/6: 0% user + 0.1% kernel
      0% 1026/traced: 0% user + 0% kernel / faults: 3568 minor 5 major
      0% 1137/media.extractor: 0% user + 0% kernel / faults: 1880 minor 3 major
      0.1% 2037/com.android.networkstack.process: 0% user + 0% kernel / faults: 910 minor 388 major
      0.1% 15813/android.process.media: 0.1% user + 0% kernel / faults: 2566 minor 240 major
      0.1% 19047/kworker/2:2: 0% user + 0.1% kernel
      0% 21439/kworker/2:1: 0% user + 0% kernel
      0% 892/android.hardware.memtrack@1.0-service: 0% user + 0% kernel / faults: 79 minor
      0.1% 36/rcuop/3: 0% user + 0.1% kernel
      0.1% 44/rcuop/4: 0% user + 0.1% kernel
      0.1% 68/rcuop/7: 0% user + 0.1% kernel
      0% 362/rot_doneq_0_0: 0% user + 0% kernel
      0% 665/android.hardware.power@1.3-service.pixel-libperfmgr: 0% user + 0% kernel / faults: 91 minor
      0.1% 17397/tty_worker_thre: 0% user + 0.1% kernel
      0.1% 18492/com.snapchat.android: 0% user + 0% kernel / faults: 732 minor 388 major
      0% 22036/com.google.android.permissioncontroller: 0% user + 0% kernel / faults: 1750 minor 713 major
      0.1% 22156/kworker/u16:7: 0% user + 0.1% kernel
      0% 24068/cds_mc_thread: 0% user + 0% kernel
      0% 8/rcu_sched: 0% user + 0% kernel
      0% 99/kcompactd0: 0% user + 0% kernel
      0% 193/spi_wdsp: 0% user + 0% kernel
      0% 828/netd: 0% user + 0% kernel / faults: 280 minor 1 major
      0% 923/msm_irqbalance: 0% user + 0% kernel / faults: 52 minor
      0% 5502/com.google.android.apps.scone: 0% user + 0% kernel / faults: 271 minor 138 major
      0% 52/rcuop/5: 0% user + 0% kernel
      0% 625/hwservicemanager: 0% user + 0% kernel / faults: 242 minor 4 major
      0% 662/android.hardware.gatekeeper@1.0-service-qti: 0% user + 0% kernel / faults: 79 minor 3 major
      0% 1135/iorapd: 0% user + 0% kernel / faults: 305 minor 5 major
      0% 1147/wificond: 0% user + 0% kernel / faults: 140 minor 1 major
      0% 1680/iorap.prefetcherd: 0% user + 0% kernel / faults: 931 minor 84 major
      0% 2626/irq/35-1008000.: 0% user + 0% kernel
      0% 3283/com.google.android.googlequicksearchbox:interactor: 0% user + 0% kernel / faults: 508 minor 644 major
      0% 8170/com.android.chrome: 0% user + 0% kernel / faults: 670 minor 538 major
      0% 22070/android.process.acore: 0% user + 0% kernel / faults: 307 minor 3 major
      0% 22293/kworker/5:2: 0% user + 0% kernel / faults: 10 minor
      0% 22379/kworker/4:1: 0% user + 0% kernel / faults: 8 minor
      0% 22410/kworker/u16:6: 0% user + 0% kernel
      0% 1/init: 0% user + 0% kernel / faults: 101 minor 1 major
      0% 11/rcuos/0: 0% user + 0% kernel
      0% 20/rcuop/1: 0% user + 0% kernel
      0% 32/migration/3: 0% user + 0% kernel
      0% 33/ksoftirqd/3: 0% user + 0% kernel
      0% 61/rcuos/6: 0% user + 0% kernel
      0% 69/rcuos/7: 0% user + 0% kernel
      0% 85/smem_native_dsp: 0% user + 0% kernel
      0% 188/vsync_retire_wo: 0% user + 0% kernel
      0% 215/hwrng: 0% user + 0% kernel
      0% 549/kworker/6:1H: 0% user + 0% kernel
      0% 628/sugov:0: 0% user + 0% kernel
      0% 659/android.system.suspend@1.0-service: 0% user + 0% kernel / faults: 44 minor
      0% 663/android.hardware.keymaster@3.0-service-qti: 0% user + 0% kernel / faults: 70 minor 18 major
      0% 713/wlan_logging_th: 0% user + 0% kernel
      0% 768/loop7: 0% user + 0% kernel
      0% 809/loop26: 0% user + 0% kernel
      0% 866/zygote: 0% user + 0% kernel / faults: 1204 minor 27 major
      0% 874/android.hidl.allocator@1.0-service: 0% user + 0% kernel / faults: 108 minor
      0% 883/kworker/3:1H: 0% user + 0% kernel
      0% 904/android.hardware.thermal@2.0-service.pixel: 0% user + 0% kernel / faults: 94 minor
      0% 931/sensors.qcom: 0% user + 0% kernel / faults: 111 minor
2020-11-23 18:14:38.537 1350-23366/? E/ActivityManager:   0% 1122/ipacm: 0% user + 0% kernel / faults: 73 minor
      0% 1136/keystore: 0% user + 0% kernel / faults: 389 minor 17 major
      0% 1138/media.metrics: 0% user + 0% kernel / faults: 401 minor 31 major
      0% 1150/rild: 0% user + 0% kernel / faults: 28 minor 1 major
      0% 1176/gatekeeperd: 0% user + 0% kernel / faults: 641 minor 53 major
      0% 1862/com.google.modemservice: 0% user + 0% kernel / faults: 721 minor 6 major
      0% 1958/com.qualcomm.qcrilmsgtunnel: 0% user + 0% kernel / faults: 578 minor 3 major
      0% 2005/webview_zygote: 0% user + 0% kernel / faults: 157 minor
      0% 2168/.dataservices: 0% user + 0% kernel / faults: 115 minor 42 major
      0% 3312/com.android.nfc: 0% user + 0% kernel / faults: 195 minor 19 major
      0% 3360/com.google.SSRestartDetector: 0% user + 0% kernel / faults: 106 minor 96 major
      0% 4269/com.google.android.googlequicksearchbox:assistant: 0% user + 0% kernel / faults: 15 minor
      0% 21460/kworker/u16:8: 0% user + 0% kernel
      0% 21556/kworker/6:1: 0% user + 0% kernel / faults: 2 minor
      0% 21644/com.google.android.apps.nbu.files: 0% user + 0% kernel / faults: 69 minor 102 major
      0% 22266/kworker/1:3: 0% user + 0% kernel
      0% 22284/kworker/3:0: 0% user + 0% kernel
      0% 22400/kworker/7:2: 0% user + 0% kernel / faults: 10 minor
      0% 22408/kworker/u16:1: 0% user + 0% kernel
      0% 24069/cds_ol_rx_threa: 0% user + 0% kernel
     +0% 22481/com.google.process.gapps: 0% user + 0% kernel
     +0% 22540/com.google.android.tts: 0% user + 0% kernel
     +0% 22580/kworker/3:1: 0% user + 0% kernel
     +0% 22584/com.google.android.euicc: 0% user + 0% kernel
     +0% 22610/com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0: 0% user + 0% kernel
     +0% 22700/com.android.keychain: 0% user + 0% kernel
     +0% 22723/com.google.android.apps.wellbeing: 0% user + 0% kernel
     +0% 22735/com.android.vending: 0% user + 0% kernel
     +0% 22764/com.google.android.gms.ui: 0% user + 0% kernel
     +0% 22771/kworker/u17:1: 0% user + 0% kernel
     +0% 22803/com.gowtham.videotrimmer: 0% user + 0% kernel
     +0% 22955/kworker/u16:13: 0% user + 0% kernel
     +0% 22966/com.android.vending:download_service: 0% user + 0% kernel
     +0% 23018/kworker/2:0: 0% user + 0% kernel
     +0% 23023/android:ui: 0% user + 0% kernel
     +0% 23048/com.google.android.documentsui: 0% user + 0% kernel
     +0% 23073/com.google.android.apps.docs: 0% user + 0% kernel
     +0% 23148/com.android.externalstorage: 0% user + 0% kernel
     +0% 23252/kworker/2:3: 0% user + 0% kernel
     +0% 23280/rot_fenceq_0_8: 0% user + 0% kernel
    37% TOTAL: 25% user + 10% kernel + 0.5% iowait + 0.5% irq + 0.2% softirq
    CPU usage from 37ms to 429ms later (2020-11-23 18:14:35.192 to 2020-11-23 18:14:35.583):
      96% 19268/com.ezidox.contributor: 96% user + 0% kernel
        96% 19304/Thread-4: 96% user + 0% kernel
      63% 1153/media.swcodec: 41% user + 22% kernel / faults: 21612 minor
        60% 23365/oid.avc.decoder: 38% user + 22% kernel
        3.1% 23278/oid.aac.decoder: 3.1% user + 0% kernel
      38% 1350/system_server: 9.5% user + 28% kernel / faults: 547 minor
        31% 23366/AnrConsumer: 6.3% user + 25% kernel
      25% 1140/mediaserver: 25% user + 0% kernel / faults: 145 minor
        25% 30374/Binder:1140_7: 25% user + 0% kernel
      14% 666/surfaceflinger: 11% user + 2.9% kernel / faults: 1 minor
        8.7% 666/surfaceflinger: 5.8% user + 2.9% kernel
        2.9% 698/Binder:666_2: 0% user + 2.9% kernel
        2.9% 699/surfaceflinger: 0% user + 2.9% kernel
      20% 22803/com.gowtham.videotrimmer: 16% user + 4% kernel / faults: 205 minor
        12% 23263/ExoPlayer:Playb: 12% user + 0% kernel
        4% 23268/MediaCodec_loop: 4% user + 0% kernel
        4% 23274/MediaCodec_loop: 4% user + 0% kernel
      9.4% 1148/media.codec: 3.1% user + 6.3% kernel
        3.1% 23271/VideoDecCallBac: 0% user + 3.1% kernel
        3.1% 23272/VideoDecMsgThre: 0% user + 3.1% kernel
        3.1% 23273/OMXCallbackDisp: 3.1% user + 0% kernel
      2.5% 61/rcuos/6: 0% user + 2.5% kernel
      2.6% 150/kswapd0: 0% user + 2.6% kernel
      2.7% 360/rot_commitq_0_0: 0% user + 2.7% kernel
2020-11-23 18:14:38.537 1350-23366/? E/ActivityManager:   2.9% 672/android.hardware.graphics.composer@2.1-service: 0% user + 2.9% kernel
        2.9% 672/composer@2.1-se: 0% user + 2.9% kernel
      3% 902/android.hardware.sensors@1.0-service: 3% user + 0% kernel
      3% 965/audioserver: 3% user + 0% kernel
      3.7% 19435/x.x.x: 3.7% user + 0% kernel / faults: 1 minor
        3.7% 19435/x.x.x: 3.7% user + 0% kernel
      3.9% 22383/mdss_fb0: 0% user + 3.9% kernel
    35% TOTAL: 25% user + 10% kernel + 0.3% irq + 0.3% softirq
2020-11-23 18:14:39.058 1140-18157/? E/FrameDecoder: failed to get video frame (err -11)
a914-gowtham commented 4 years ago

Thanks. I haven't tried this library on Android 11 devices yet. I will check this issue Asap

MujammilAhamed commented 4 years ago

ANR occurs in most of the OS versions

MujammilAhamed commented 4 years ago

It takes more time to Place the Multiple Thumb Images and it's in the UI thread. So it's causing ANR. I can see a black box initially when the ActVideoTrimmer is viewed.

MujammilAhamed commented 4 years ago

@a914-gowtham Any update on the fix

a914-gowtham commented 4 years ago

Not yet.I will fix the issue by tomorrow night

a914-gowtham commented 4 years ago

Hi mujammil, I have fixed this issue and added some improvements to this latest 1.5.0 version. I tested this issue with the emulator in my machine. Can you try this out and let me know whether everything works fine or not.

MujammilAhamed commented 4 years ago

Thanks @a914-gowtham for the fix. Let me check and get back to you

MujammilAhamed commented 4 years ago

ANR doesn't occurs in the latest version -1.5.1. But the ThumbNail takes more time to load.

Thanks for the update

a914-gowtham commented 4 years ago

Yeah..i just noticed that. I was using a wrong way to load thumbnail. Use 1.5.2 I'm using glide now