pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.18k stars 1.55k forks source link

onLoadResource, not working on API 26(Android 6, 7) #1014

Open jpolstre opened 2 years ago

jpolstre commented 2 years ago

onLoadResource, not working on Android 6. I am using flutter_inappwebview 5.3.2:

min example: HeadlessInAppWebView( initialUrlRequest: URLRequest(url: Uri.parse(url)), initialOptions: InAppWebViewGroupOptions( crossPlatform: InAppWebViewOptions( useOnLoadResource: true, mediaPlaybackRequiresUserGesture: false, ), android: AndroidInAppWebViewOptions( useShouldInterceptRequest: true, ), ios: IOSInAppWebViewOptions( allowsInlineMediaPlayback: true, ), onLoadResource: (controller, b) { final url = b.url.toString(); print('onLoadResource---->$url');.//<--does not print anything on Android 6 and Android 7, Android 8 it works. }, ),

flutter doctor: [✓] Flutter (Channel stable, 2.5.2, on Ubuntu 20.04.3 LTS 5.4.0-80-generic, locale es_BO.UTF-8) • Flutter version 2.5.2 at /home/marcelo/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 3595343e20 (3 weeks ago), 2021-09-30 12:58:18 -0700 • Engine revision 6ac856380f • Dart version 2.14.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /home/marcelo/Android/Sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted.

[✓] Chrome - develop for the web • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.20.0 • ninja version 1.10.0 • pkg-config version 0.29.1

[✓] Android Studio (version 2020.3) • Android Studio at /snap/android-studio/115/android-studio • Flutter plugin version 59.0.2 • Dart plugin version 203.8292 • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio • Android Studio at /snap/android-studio/current/android-studio/ • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • android-studio-dir = /snap/android-studio/current/android-studio/ • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.61.1) • VS Code at /usr/share/code • Flutter extension version 3.27.0

[✓] Connected device (3 available) • SM G9350 (mobile) • 0123456789ABCDEF • android-arm • Android 6.0.1 (API 22) • Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.3 LTS 5.4.0-80-generic • Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.81

debug console: D/MALI (15968): _egl_make_current:906: [MALI] Map ctx 0x40000001 to ctx 0xb85d3060 D/Surface (15968): Surface::setBuffersDimensions(this=0xb86cbf98,w=720,h=1280) D/MALI (15968): _egl_make_current:857: [MALI] make current with display 0x1, context 0x40000001, state 0xb86c2120 D/MALI (15968): _egl_make_current:872: [MALI] Map dpy 0x1 to dpy 0xb84645d8 D/MALI (15968): _egl_make_current:906: [MALI] Map ctx 0x40000001 to ctx 0xb85d3060 D/Surface (15968): Surface::setBuffersDimensions(this=0xb86cbf98,w=720,h=1280) D/MALI (15968): _egl_make_current:857: [MALI] make current with display 0x1, context 0x40000001, state 0xb86c2120 D/MALI (15968): _egl_make_current:872: [MALI] Map dpy 0x1 to dpy 0xb84645d8 D/MALI (15968): _egl_make_current:906: [MALI] Map ctx 0x40000001 to ctx 0xb85d3060 D/Surface (15968): Surface::setBuffersDimensions(this=0xb86cbf98,w=720,h=1280) D/MALI (15968): _egl_make_current:857: [MALI] make current with display 0x1, context 0x40000001, state 0xb86c2120 D/MALI (15968): _egl_make_current:872: [MALI] Map dpy 0x1 to dpy 0xb84645d8 D/MALI (15968): _egl_make_current:906: [MALI] Map ctx 0x40000001 to ctx 0xb85d3060 D/Surface (15968): Surface::setBuffersDimensions(this=0xb86cbf98,w=720,h=1280) D/MALI (15968): _egl_make_current:857: [MALI] make current with display 0x1, context 0x40000001, state 0xb86c2120 D/MALI (15968): _egl_make_current:872: [MALI] Map dpy 0x1 to dpy 0xb84645d8 D/MALI (15968): _egl_make_current:906: [MALI] Map ctx 0x40000001 to ctx 0xb85d3060 D/Surface (15968): Surface::setBuffersDimensions(this=0xb86cbf98,w=720,h=1280) D/MALI (15968): _egl_make_current:857: [MALI] make current with display 0x1, context 0x40000001, state 0xb86c2120 D/MALI (15968): _egl_make_current:872: [MALI] Map dpy 0x1 to dpy 0xb84645d8 D/MALI (15968): _egl_make_current:906: [MALI] Map __ctx 0x40000001 to ctx 0xb85d3060 D/WebView (15968): evaluateJavascript=if (document.readyState === 'interactive' || document.readyState === 'complete') { if (window.flutter_inappwebview != null && (window.flutter_inappwebview._userScriptsAtDocumentStartLoaded == null || !window.flutter_inappwebview._userScriptsAtDocumentStartLoaded)) { window.flutter_inappwebview._userScriptsAtDocumentStartLoaded = true; ;if (window.Promise == null) { !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.RSVP={})}(this,function(t){"use strict";function e(t){var e=t._promiseCallbacks;return e||(e=t._promiseCallbacks={}),e}var r={mixin:function(t){return t.on=this.on,t.off=this.off,t.trigger=this.trigger,t._promiseCallbacks=void 0,t},on:function(t,r){if("function"!=typeof r)throw new TypeError("Callback must be a function");var n=e(this),o=n[t];o||(o=n[t]=[]),-1===o.indexOf(r)&&o.push(r)},off:function(t,r){var n=e(this);if(r){var o=n[t],i=o.indexOf(r);-1!==i&&o.splice(i,1)}else n[t]=[]},trigger:function(t,r,n){var o=e(this)[t];if(o)for(var i=0;i<o.length;i++)(0,o[i])(r,n)}},n={instrument:!1};function o(t,e){if(2!==arguments.length)return n[t];n[t]=e}r.mixin(n);var i=[];function s(t,e,r){1===i.push({name:t,payload:{key:e._guidKey,id:e._id,eventName:t,detail:e._result,childId:r&&r._id,label:e._label,timeStamp:Date.now(),error:n["instrument-with-stack"]?new Error(e.label):null}})&&setTimeout(function(){for(var t=0;t<i.length;t++){var e=i[t],r=e.payload;r.guid=r.key+r.id,r.childGuid=r.key+r.childId,r.error&&(r.stack=r.error.stack),n.trigger(e.name,e.payload)}i.length=0},50)}function u(t,e){if(t&&"object"==typeof t&&t.constructor===this)return t;var r=new this(c,e);return m(r,t),r}function c(){}var a=void 0,f=1,l=2,h={error:null};function p(t){try{return t.then}catch(t){return h.error=t,h}}var y=void 0;function (){try{var t=y;return y=null,t.apply(this,arguments)}catch(t){return h.error=t,h}}function v(t){return y=t,_}function d(t,e,r){if(e.constructor===t.constructor&&r===A&&t.constructor.resolve===u)!function(t,e){e._state===f?b(t,e._result):e._state===l?(e._onError=null,g(t,e._result)):j(e,void 0,function(r){e===r?b(t,r):m(t,r)},function(e){return g(t,e)})}(t,e);else if(r===h){var o=h.error;h.error=null,g(t,o)}else"function"==typeof r?function(t,e,r){n.async(function(t){var n=!1,o=v(r).call(e,function(r){n||(n=!0,e===r?b(t,r):m(t,r))},function(e){n||(n=!0,g(t,e))},"Settle: "+(t._label||" unknown promise"));if(!n&&o===h){n=!0;var i=h.error;h.error=null,g(t,i)}},t)}(t,e,r):b(t,e)}function m(t,e){var r,n;t===e?b(t,e):(n=typeof(r=e),null===r||"object"!==n&&"function"!==n?b(t,e):d(t,e,p(e)))}function w(t){t._onError&&t._onError(t._result),O(t)}function b(t,e){t._state===a&&(t._result=e,t._state=f,0===t._subscribers.length?n.instrument&&s("fulfilled",t):n.async(O,t))}function g(t,e){t._state===a&&(t._state=l,t._result=e,n.async(w,t))}function j(t,e,r,o){var i=t._subscribers,s=i.length;t._onError=null,i[s]=e,i[s+f]=r,i[s+l]=o,0===s&&t._state&&n.async(O,t)}function O(t){var e=t._subscribers,r=t._state;if(n.instrument&&s(r===f?"fulfilled":"rejected",t),0!==e.length){for(var o=void 0,i=void 0,u=t._result,c=0;c<e.length;c+=3)o=e[c],i=e[c+r],o?E(r,o,i,u):i(u);t._subscribers.length=0}}function E(t,e,r,n){var o="function"==typeof r,i=void 0;if(i=o?v(r)(n):n,e._state!==a);else if(i===e)g(e,new TypeError("A promises callback cannot return that same promise."));else if(i===h){var s=h.error;h.error=null,g(e,s)}else o?m(e,i):t===f?b(e,i):t===l&&g(e,i)}function A(t,e,r){var o=this._state;if(o===f&&!t||o===l&&!e)return n.instrument&&s("chained",this,this),this;this._onError=null;var i=new this.constructor(c,r),u=this._result;if(n.instrument&&s("chained",this,i),o===a)j(this,i,t,e);else{var h=o===f?t:e;n.async(function(){return E(o,i,h,u)})}return i}var T=function(){function t(t,e,r,n){this._instanceConstructor=t,this.promise=new t(c,n),this._abortOnReject=r,this._isUsingOwnPromise=t===k,this._isUsingOwnResolve=t.resolve===u,this._init.apply(this,arguments)}return t.prototype._init=function

github-actions[bot] commented 2 years ago

👋 @jpolstre

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!