Open allister-beamable opened 3 weeks ago
When stepping through in a debugger, we found that the exception was thrown when PlatformRequester tries to resolve IPlatformService via dependency injection: https://github.com/beamable/BeamableProduct/blob/1.19.22/client/Packages/com.beamable/Runtime/Core/Platform/SDK/PlatformRequester.cs#L423
The exception is being thrown from code that is shared between Runtime and Editor. The Runtime properly fills out a Dependency Injectable scope; but the Editor does not. When this error pathway happens in the Editor, the Editor tries to use DI to resolve a dependency that has not been registered.
Instead of using the IPlatformService
, we should use the IUserContext
, and implement the IUserContext
on the Beamable.Editor.AccountService
(which is where the editor account info is stored), and then inject the IUserContext
into the BeamEditor
DI scope.
public long UserId => Account.user.id;
Describe the Bug
When the access token for a developer in Unity Editor has passed its 10-day expiration, the SDK fails to fully initialize and prints a bunch of errors in the console, including
Failed to refresh account
andException: Service not found IPlatformService
. It is possible to solve this by logging out and logging back in, but this is not an ideal user experience.Steps to reproduce
Expected behavior
Actual behavior
Metadata
Additional information
When this situation occurs, developers can resolve it by using Beamable Toolbox to log out and log back in again.
The refresh failure only seems to occur rarely, such as when a developer goes on vacation or other circumstances that lead them to leave the project aside for multiple days; chances are that when developers are interacting with the SDK on a regular workday basis, the SDK is able to preemptively refresh the token before it actually fully expires.