modesttree / Zenject

Dependency Injection Framework for Unity3D
MIT License
2.5k stars 273 forks source link

Method with attribute [Inject] is called twice when a class binded as NonLazy in ProjectInstaller. Only on Android. #251

Open corvax101 opened 3 years ago

corvax101 commented 3 years ago

Describe the bug Method with attribute [Inject] is called twice when a class binded as NonLazy in ProjectInstaller. Only on Android. Binding happens like this:

Container .Bind< ClassName >() .ToSelf() .FromNewComponentOnNewGameObject() .AsSingle() .NonLazy();

To Reproduce Steps to reproduce the behavior:

  1. Bind class having method with attribute [Inject] in ProjectInstaller as specified above.
  2. Create a SceneContext on the scene
  3. Build this scene as APK file on Android device and run application

Expected behavior Method with attribute [Inject] called one time when object is instantiating.

Actual behavior Method with attribute [Inject] called twice times when object is instantiating.

Extenject and Unity info (please complete the following information):

Additional context Android version on target device: 8.0.0 Target device: Honor 9 (STF-L09) If change NonLazy binding to Lazy then method with attribute [Inject] will be called one time. Logs with stacktrace: Zenject non-lazy bug.txt