You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/02/17 10:41:32 UTC

[GitHub] [cordova-android] jblejder opened a new issue #1164: Provide PluginEntry with plugin instances causes assertion to crash app

jblejder opened a new issue #1164:
URL: https://github.com/apache/cordova-android/issues/1164


   # Bug Report
   
   ## Problem
   
   After upgrade AGP to 4.1.0 our cordova based solution started to crash on Debug builds.
   
   ### What is expected to happen?
   
   Not crash ;)
   
   ### What does actually happen?
   We use Cordova in a way where we provide [PluginEntry](https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/PluginEntry.java#L51) with existing instance of CordovaServices.
   
   This started to crash after we upgraded to AGP 4.1.0 from assertions [HERE](https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L52)
   
   Turns out AGP 4.1.0 changed config so all assertions will always throw on debug builds 
   >**Assertions in debug builds**
   >When you build the debug version of your app using Android Gradle plugin 4.1.0 and higher, the built-in compiler (D8) will >rewrite your app's code to enable assertions at compile time, so you always have assertion checks active.
   source: [AGP release notes](https://developer.android.com/studio/releases/gradle-plugin#4.1-debug-assertions)
   
   ## Information
   So far I found out that plugins provided from outside are initialized twice here [CordovaWebViewImpl:init](https://github.com/apache/cordova-android/blob/3081e5e6e91c32e507423411196b184325baa935/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L97)
   
   First is when PluginManager is created on [L:103](https://github.com/apache/cordova-android/blob/3081e5e6e91c32e507423411196b184325baa935/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L103)
   As `plugin.entry` is not null it is initialised here first time
   <img width="647" alt="Screen Shot 2021-02-17 at 11 31 02 am" src="https://user-images.githubusercontent.com/17861372/108191625-75642680-7167-11eb-9538-5e2412960e8c.png">
   
   Right arter this in `CordovaWebViewImpl:init` calls [pluginManager.init()](https://github.com/apache/cordova-android/blob/3081e5e6e91c32e507423411196b184325baa935/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L117) which basically initialize plugins again and causes assertion to fail.
   
   What more I found is that if only `PluginEntry.load` could be set to false if plugin instance is provided it would not initialize them twice. Not sure if it breaks something else though.
   
   It seems like a bug to me but if it's not please tell me what is the proper way to provide instances of plugin from outside.
   
   
   ### Environment, Platform, Device
   Android, Any
   
   ### Version information
   8.1.0 - because it's last version that supports android 21
   
   ## Checklist
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] erisu closed issue #1164: Provide PluginEntry with plugin instances causes assertion to crash app

Posted by GitBox <gi...@apache.org>.
erisu closed issue #1164:
URL: https://github.com/apache/cordova-android/issues/1164


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] jblejder edited a comment on issue #1164: Provide PluginEntry with plugin instances causes assertion to crash app

Posted by GitBox <gi...@apache.org>.
jblejder edited a comment on issue #1164:
URL: https://github.com/apache/cordova-android/issues/1164#issuecomment-781224436


   I made a PR in which test can reproduce issue https://github.com/jblejder/cordova-android/pull/1


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] jblejder commented on issue #1164: Provide PluginEntry with plugin instances causes assertion to crash app

Posted by GitBox <gi...@apache.org>.
jblejder commented on issue #1164:
URL: https://github.com/apache/cordova-android/issues/1164#issuecomment-781224436


   I made a PR in which test can reproduce issue
   https://github.com/jblejder/cordova-android/pull/1


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org