Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Feedback Issue with WaitForCompletion

Discussion in 'Localization Tools' started by dlorre, Jun 20, 2023.

  1. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    I've had an issue like this:

    UIController:

    Code (csharp):
    1.  
    2.         private void Start()
    3.         {
    4. ...
    5.             _ = readyToGo();
    6.         }
    7.  
    8.         private async Awaitable readyToGo()
    9.         {
    10.             await Awaitable.MainThreadAsync();
    11. ...
    12.             GameController.Instance.ReadyToGoEvent.Invoke();
    13.         }
    14.  
    15.  
    GameController:

    Code (csharp):
    1.  
    2.  
    3.         private void OnEnable()
    4.         {
    5.             LocalizationSettings.InitializationOperation.WaitForCompletion();
    6.         }
    7.         private void ReadyToGo()
    8.         {
    9.             /* localization call here */
    10.         }
    11.  
    12.  
    It seems that sometimes ReadyToGo() is called before OnEnable and I had localization errors so I added WaitForCompletion() in ReadyToGo as well. For the moment I haven't any localization errors any longer.

    upload_2023-6-20_8-3-4.png

    This is the kind of errors I get, I also get them when the app is not running in the editor, when I receive events from a stream, it seems that the stream is still running even when the editor is stopped.
     
    Last edited: Jun 20, 2023
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    What version of the package are you using? We have some issues with WaitForCompletion not waiting for Addressables to initialize, we have a fix for that in the next patch release.
     
  3. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Do you already know when this patch release arrives? We have the same problem as well.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    Its currently with QA, potentially by the end of the week if QA doesn't find any issues. I can't give an exact date im afraid.
     
    Onat-H likes this.
  5. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    I'm using package version 1.4.3, however I think that in this case, it's more an issue of OnEnable being called after the other script Start, which is why I just mentioned this as feedback rather than bug.

    Anyway, by adding WaitForCompletion in ReadyToGo() the error did not reappear but that might be related to what you say.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    You shouldn't need to call LocalizationSettings.InitializationOperation, it exists as a way to perform loading upfront however not calling it is fine, the loading will just be done the first time a call is made. So if you are getting errors due to it not being called then that sounds like a bug. Could you please file a bug report so we can investigate it?
    https://unity3d.com/unity/qa/bug-reporting
     
  7. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    If I can isolate the bug I will but it's difficult because it does not reproduce everytime, only when Start() fires before OnEnable().