浏览代码

disable incremental gc by default

/main
siyao 3 年前
当前提交
16c8a620
共有 4 个文件被更改,包括 14 次插入4 次删除
  1. 3
      README-ZH.md
  2. 2
      README.md
  3. 2
      com.unity.uiwidgets/Runtime/engine/UIWidgetsGlobalConfiguration.cs
  4. 11
      com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs

3
README-ZH.md


#### 八、移动设备优化
目前在默认情况下,为了保证流畅度,项目在各个平台上均会以最高的刷新频率运行。不过您可以通过在代码中设置```UIWidgetsGlobalConfiguration.EnableAutoAdjustFramerate = true```的方式来开启自动降帧的功能:该功能开启后,在UI内容不变的情况下我们将降低项目的刷新率来降低耗电。
在移动设备上UI绘制的流畅度受到GC影响较大。项目默认会开启OnDemandGC来接管并优化整体GC效果。如果您不需要GC被UIWidgets控制,请在代码中设置```UIWidgetsGlobalConfiguration.EnableIncrementalGC = false```。
在移动设备上UI绘制的流畅度受到GC影响较大。如有卡顿,例如滑动掉帧。可开启OnDemandGC, UIWidgets将接管并优化整体GC效果,请在代码中设置```UIWidgetsGlobalConfiguration.EnableIncrementalGC = true```,并开启```Project Setting -> Player -> Other Settings -> Use incremental GC```。
## 调试UIWidgets应用程序

2
README.md


#### Performance Optimization on Mobile devices
By setting ```UIWidgetsGlobalConfiguration.EnableAutoAdjustFramerate = true``` in your project, UIWidgets will drop the frame rate of your App to 0 if the UI contents of UIWidgetsPanel is not changed for some time. This will help to prevent battery drain on mobile devices significantly. Note that this feature is disabled by default.
Long time garbage collection may cause App to stuck frequently. In UIWidgets we enable incremental garbage collection to avoid it. However, you can disable this feature by setting ```UIWidgetsGlobalConfiguration.EnableIncrementalGC = false```.
Long time garbage collection may cause App to stuck frequently. You can enable incremental garbage collection to avoid it. You can enable this feature by setting ```UIWidgetsGlobalConfiguration.EnableIncrementalGC = true```, and enabling ```Project Setting -> Player -> Other Settings -> Use incremental GC```.
## Debug UIWidgets Application

2
com.unity.uiwidgets/Runtime/engine/UIWidgetsGlobalConfiguration.cs


public static bool EnableAutoAdjustFramerate = false;
//enable incremental gc by default
public static bool EnableIncrementalGC = true;
public static bool EnableIncrementalGC = false;
//disable debug at runtime by default
public static bool EnableDebugAtRuntime = false;

11
com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs


}
}
void TryDisableOnDemandGC()
{
if (UIWidgetsGlobalConfiguration.EnableIncrementalGC)
{
GarbageCollector.GCMode = GarbageCollector.Mode.Enabled;
}
}
void CollectGarbageOnDemand()
{
if (!UIWidgetsGlobalConfiguration.EnableIncrementalGC)

_wrapper = null;
texture = null;
Input_OnDisable();
#if !UNITY_EDITOR
TryDisableOnDemandGC();
#endif
base.OnDisable();
}

正在加载...
取消
保存