iOS 上的 Firebase 远程配置 ArgumentOutOfRangeException

Posted

技术标签:

【中文标题】iOS 上的 Firebase 远程配置 ArgumentOutOfRangeException【英文标题】:Firebase Remote Config ArgumentOutOfRangeException on iOS 【发布时间】:2021-09-09 01:02:23 【问题描述】:

ios 上,Firebase 远程配置抛出 ArgumentOutOfRangeException:

Exception: ArgumentOutOfRangeException: Value to add was out of range.
  Parameter name: value
  System.DateTime.TimeToTicks (System.Int32 hour, System.Int32 minute, System.Int32 second) (at <00000000000000000000000000000000>:0)
  Rebar.GameData.RemoteConfigFetcher+<>c__DisplayClass20_0.<Refresh>b__1 () (at <00000000000000000000000000000000>:0)
  System.Threading.ContextCallback.Invoke (System.Object state) (at <00000000000000000000000000000000>:0)
  System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <00000000000000000000000000000000>:0)
  System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () (at <00000000000000000000000000000000>:0)
  System.Action.Invoke () (at <00000000000000000000000000000000>:0)
  System.Threading.ContextCallback.Invoke (System.Object state) (at <00000000000000000000000000000000>:0)
  System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) (at <00000000000000000000000000000000>:0)
  System.Threading.Tasks.Task.FinishContinuations () (at <00000000000000000000000000000000>:0)
  System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) (at <00000000000000000000000000000000>:0)
  System.Threading.Tasks.TaskCompletionSource`1[TResult].TrySetResult (TResult result) (at <00000000000000000000000000000000>:0)
  System.Threading.Tasks.TaskCompletionSource`1[TResult].SetResult (TResult result) (at <00000000000000000000000000000000>:0)
  Firebase.FutureVoid+<GetTask>c__AnonStorey0.<>m__0 () (at <00000000000000000000000000000000>:0)
  Firebase.FutureVoid+Action.Invoke () (at <00000000000000000000000000000000>:0)
  Firebase.FutureVoid.SWIG_CompletionDispatcher (System.Int32 key) (at <00000000000000000000000000000000>:0)
  Firebase.AppUtil.PollCallbacks () (at <00000000000000000000000000000000>:0)
  Firebase.Platform.FirebaseHandler.Update () (at <00000000000000000000000000000000>:0)
  Rebar.GameData.<>c__DisplayClass20_0:<Refresh>b__1()
  System.Threading.Tasks.TaskCompletionSource`1:SetResult(TResult)
  Firebase.<GetTask>c__AnonStorey0:<>m__0()
  Firebase.Action:Invoke()
  Firebase.FutureVoid:SWIG_CompletionDispatcher(Int32)
  Firebase.AppUtil:PollCallbacks()
  Firebase.Platform.FirebaseHandler:Update()

我不确定此错误可能来自何处或可能导致它的原因。前几天还在工作。

我们在 Unity 2019.4.17f1 中运行 Firebase 7.2.0。问题似乎是特定于 iOS 的。

相关部分代码:

private async Task<Dictionary<string, object> FetchAndActivateAsync()
  _fetchState = FetchState.Fetching;
  await _remoteConfig.FetchAsync(TimeSpan.Zero);
  _fetchState = FetchState.Applying;
  if(_remoteConfig.Info.LastFetchStatus == LastFetchStatus.Failure)
    _fetchState = FetchState.Fail;
    return null;
  
  await _remoteConfig.ActivateAsync();
  var configs = new Dictionary<string, object>();
  foreach(string key in _remoteConfig.Keys)
    var configValue = _remoteConfig.GetValue(key);
    AddConfig(key, configValue, configs); //just does some sorting and translating
  
  _fetchState = FetchState.Success;
  return configs;

【问题讨论】:

【参考方案1】:

似乎实际上是由在请求未被限制时访问RemoteConfig.ConfigInfo.ThrottledEndTime 的调试日志引起的。分解日志并首先检查LastFetchFailureReason,似乎已经解决了这个问题。

【讨论】:

以上是关于iOS 上的 Firebase 远程配置 ArgumentOutOfRangeException的主要内容,如果未能解决你的问题,请参考以下文章

Firebase 远程配置 iOS 教程

Swift/iOS - Firebase 远程配置获取值永远不会完成

尝试使用 Firebase 远程配置运行 Flutter WEB 应用程序时出错 [关闭]

iOS 上的 Firebase Crashlytics 设置?

Firebase 动态链接在 iOS 14 上的 Safari 中留下空白页面

在 iOS 上配置 Firebase 应用后,Branch.io 深层链接停止工作