-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use PlatformViewLink widget for Android WebView #462
Use PlatformViewLink widget for Android WebView #462
Conversation
Thanks! I was waiting for the hybrid composition to be available on the stable channel before doing this. With hybrid composition, probably I can remove also some other workarounds. I think we need to wait when the hybrid composition is available on the stable channel in order to merge this PR, what do you think? |
that sounds good to me. :) I will keep tracking when it's merged to stable channel. |
Hello @pichillilorenzo ~ 1.20 and 1.20.1 is released on flutter stable channel. If you have time to merge this PR, or integrate hybrid composition in any way in next version, it would be of great help! Thank you. :) |
@plateaukao Just tried this out for the heck of it, and it does not work. Does something need updating? I double checked myself to make sure I didn't copy anything wrong. Logs
flutter doctor -v
The lines below just flood the logs constantly and then the app crashes on debug mode.
|
Yup adding to my own AndroidManifest fixed it, thanks! Scrolling is so buttery smooth on Android now. |
@plateaukao I built a release mode app and one thing I noticed is although the webview is super smooth now, any other UI elements on a page with webview are laggy. For example if I have a navigation drawer, its animation is dropping frames. Update: here is where you might be able to see what I'm talking about - settings and webview are like butter but the drawer is laggy, same goes for every other non-webview widget in the webview page. |
@tneotia Do you running on Android 9 or below? See Hybrid-Composition#performance. It should be working fine on Android 10, i has tested on 3 devices with Android 10(2 of them have a lower performance CPU) and it looks smooth enough. |
@Doflatango ohh I see - I looked up this issue but didnt find this doc. I tested on Android 9... that is unfortunate, and grabbing a screenshot and displaying is kind of impractical. Would there be a way to just apply hybrid composition to the webview? Dont think that would be possible, just wondering. Edit: I read a little bit more and actually understand how hybrid composition works now. I feel like maybe we should wait for this considering the fact that many android devices are not Android 10+, and creating an option for using hybrid composition would likely not be feasible (correct me if I am wrong here). Hybrid composition may be on Flutter stable but I wouldn't consider it to be stable for the vast majority of Android devices - you can really feel the difference when there is any sort of animation, whether it be screen transitions, nav drawer opening/closing, etc. I really hope the Flutter team can find an acceptable solution in the near future for this, though. |
webview is not well supported in flutter for a long time, and hybrid composition is a big breakthrough for android platform, that fixes many long lasting issues. However, don't expect it's going to be stable or performant any time soon. I reported a crash issue that's 100% reproducible if you use hybrid composition webview in android, and send a PR for this issue 10 days ago, but it's not commented yet til now. I don't think supporting native platform view is of high priority in flutter dev team; that's why hybrid composition come out so late. You can check all the issues reported about platform view in these two years. So, if webview is a must for your app, suggest trying the method just mentioned(make a screenshot for it while animation is ongoing), or, just disable any significant animation while webview is used. A more aggressive step would be, to help check why current implementation is not working well with android under OS 10, and try to send PR to make it better. :) This is out of my capability although I really want to do so. |
@plateaukao yea I understand what you are saying. Frankly I'm just a college student developing an app for my school, and I dont even want to be a software engineer. I only really understand how to make a Flutter app, not the mechanics behind how the engine works. I have seen the webview is neglected for quite some time and even the official plugin has a plethora of issues. The problem for me is that my app has to be built around a webview, there is no api I can use to make an actual UI. Dont know why Flutter team doesnt have any wish to work on webview, and it's hard to tell what issues they are working on currently as it is. I will try the screenshot approach though I dont know how well that would work. I wish I could help out with this as I want flutter to become a matured platform - it has helped me in so many ways and truly is a breakthrough, but it's also outside of my capability. |
@tneotia if I were flutter dev team, with limited resource, I would also put my focus on flutter widgets and the cross platform part more, since that's the main strength of flutter since the beginning. As for supporting each platform's native view, it's easily constrained by the platform's original limitation. And sometimes even if they want to, they can only wait for that platform to have better architecture too (like what we wait for hybrid composition in flutter for a better inappwebview plugin ). Hope that hybrid composition can be stable as soon as possible so people can benefit from flutter's strength and the powerful platform view at the same time. As more and more developers start using flutter, I expect to see more and more input from community too to make it improve faster. :) |
I completely agree.. I read somewhere that it runs on android 10 well because of a newer api so your point about OS support is very valid. Imo flutter is already as powerful as React Native and its newer, just think what is achievable in the near future, especially being under Google. I believe within the next year or two we will be seeing leaps and bounds! |
Add AndroidInAppWebViewOption for using Hybrid Composition
@pichillilorenzo I think we are good to merge this if it looks good to you, since now we have an option to use this rather than forcing users to adopt Hybrid Composition. Also, no need for each user to include the |
Added missing `contextMenu` and `windowId` creation params for Android Hybrid Composition
Thanks! |
Actually I discovered a bug with this yesterday I was trying to fix, but couldn't get to it. If you don't have the This will have to be fixed before pushing a new release, do you have any idea what could be going wrong? |
Ok, I fixed also that! Thanks 👍 |
just FYI: |
Connection with issue(s)
Resolve issue: flutter/flutter#41089
[webview_flutter] Keyboard language can't change on Android (flutter/flutter#41089) is listed in issue (flutter/flutter#61133) and it's fixed by flutter PR: flutter/plugins#2883
Although this issue is reported to webview_flutter, it happens in flutter_inappwebview too, and especially for users who use google gboard as input method, and try to switch to Chinese input methods.
So, I ported the fix from webview_flutter plugin.
Testing and Review Notes
Steps:
Screenshots or Videos
Video with language switching issue
Before applying the fix, all Chinese input methods will be displayed with just QWERTY input keyboard, which does not allow users to input any Chinese characters.
Video after applying the fix
After applying the fix, the input method can be successfully switched, and be used to input Chinese.
To Do