Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [3.2.10] - 2020-04-24
* Release 3.2.10

## [3.2.10-preview.1] - 2020-04-20
* Fix Unity Frame Debugger by not stopping loaders on Pause / Stop.
* Don't stop loaders when XRGeneralSettings is disabled.
* Fix UI issue where third party providers would sometimes disappear from the provider selection UI.
  • Loading branch information
Unity Technologies committed Apr 23, 2020
1 parent 66961ff commit 0489230
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 107 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.2.10] - 2020-04-24
* Release 3.2.10

## [3.2.10-preview.1] - 2020-04-20
* Fix Unity Frame Debugger by not stopping loaders on Pause / Stop.
* Don't stop loaders when XRGeneralSettings is disabled.
* Fix UI issue where third party providers would sometimes disappear from the provider selection UI.


## [3.2.9] - 2020-04-18
* Fix linux tests in CI.

Expand Down
2 changes: 1 addition & 1 deletion Editor/Legacy/XRLegacyUninstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct LegacyPackageListRequest
public ListRequest packageListRequest;
}

private static readonly string k_PackageToRemoveQueue = "Remove Pacakge Queue";
private static readonly string k_PackageToRemoveQueue = "Remove Package Queue";
private static EditorWorkQueue<PackageRemovalOperation> s_PackageRemovelQueue => EditorWorkQueue<PackageRemovalOperation>.Instance;
private static bool hasPackageBeingRemoved => s_PackageRemovelQueue.HasWorkItems;

Expand Down
2 changes: 1 addition & 1 deletion Editor/Metadata/KnownPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static List<IXRPackage> InitKnownPackages()
loaderType = k_KnownPackageMockHMDLoader,
supportedBuildTargets = new List<BuildTargetGroup>() {
BuildTargetGroup.Standalone,
BuildTargetGroup.Android,
BuildTargetGroup.Android
}
},
}
Expand Down
172 changes: 128 additions & 44 deletions Editor/Metadata/XRPackageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ public interface IXRPackageMetadata
[InitializeOnLoad]
public class XRPackageMetadataStore
{
private const string k_WaitingPackmanQuery = "Waiting Packman Query.";
private const string k_InstallingPackage = "Installing XR Package.";
private const string k_AssigningPackage = "Assigning XR Package.";
private const string k_UninstallingPackage = "Uninstalling XR Package.";
private const string k_WaitingPackmanQuery = "XRMGT Waiting Packman Query.";
private const string k_RebuildCache = "XRMGT Rebuilding Cache.";
private const string k_InstallingPackage = "XRMGT Installing XR Package.";
private const string k_AssigningPackage = "XRMGT Assigning XR Package.";
private const string k_UninstallingPackage = "XRMGT Uninstalling XR Package.";

private static float k_TimeOutDelta = 30f;

enum InstallationState
{
New,
RebuildInstalledCache,
StartInstallation,
Installing,
Assigning,
Expand All @@ -113,8 +115,12 @@ struct LoaderAssignmentRequest
[SerializeField]
public BuildTargetGroup buildTargetGroup;
[SerializeField]
public bool rebuildRequestOnly;
[SerializeField]
public bool needsAddRequest;
[SerializeField]
public ListRequest packageListRequest;
[SerializeField]
public AddRequest packageAddRequest;
[SerializeField]
#pragma warning disable CS0649
Expand Down Expand Up @@ -144,6 +150,7 @@ struct LoaderAssignmentRequests
private static HashSet<string> s_InstallablePackages = new HashSet<string>();

internal static bool isCheckingInstallationRequirements => EditorPrefs.HasKey(k_WaitingPackmanQuery);
internal static bool isRebuildingCache => EditorPrefs.HasKey(k_RebuildCache);
internal static bool isInstallingPackages => EditorPrefs.HasKey(k_InstallingPackage);
internal static bool isUninstallingPackages => EditorPrefs.HasKey(k_UninstallingPackage);
internal static bool isAssigningLoaders => EditorPrefs.HasKey(k_AssigningPackage);
Expand Down Expand Up @@ -174,6 +181,8 @@ private static void UpdateInstallablePackages()
}

s_SearchRequest = null;

RebuildInstalledCache();
}

internal static void InitKnownPackages()
Expand All @@ -187,22 +196,27 @@ internal static void InitKnownPackages()
static XRPackageMetadataStore()
{
InitKnownPackages();
s_SearchRequest = Client.SearchAll(false);

EditorApplication.playModeStateChanged += PlayModeStateChanged;

if (EditorApplication.isPlaying || EditorApplication.isPaused)
return;


s_SearchRequest = Client.SearchAll(false);

EditorApplication.update += UpdateInstallablePackages;
EditorApplication.update += WaitingOnSearchQuery;
EditorApplication.update += MonitorPackageInstallation;
EditorApplication.update += MonitorPackageUninstall;
EditorApplication.update += AssignAnyRequestedLoadersUpdate;
EditorApplication.update += RebuildCache;
}

private static void PlayModeStateChanged(PlayModeStateChange state)
{
// Transfer installed package list over to play mode so that we don't need to
// rebuild the cache with an expensive PackMan call.
const string k_InstalledPackagesKey = "XR Management Installed Packages Cache";
switch(state)
{
Expand All @@ -217,7 +231,7 @@ private static void PlayModeStateChanged(PlayModeStateChange state)
if (sb.Length > 0)
EditorPrefs.SetString(k_InstalledPackagesKey, sb.ToString());
break;
case PlayModeStateChange.EnteredEditMode:
case PlayModeStateChange.EnteredPlayMode:
string installedPackages = "";
if (EditorPrefs.HasKey(k_InstalledPackagesKey))
{
Expand Down Expand Up @@ -286,6 +300,90 @@ private static LoaderAssignmentRequests GetAllRequestsInQueue(string queueName)
return reqs;
}

internal static void RebuildInstalledCache()
{
if (isRebuildingCache)
return;

LoaderAssignmentRequest req = new LoaderAssignmentRequest();
req.installationState = InstallationState.RebuildInstalledCache;
req.rebuildRequestOnly = true;
QueueLoaderRequest(req);
}

private static void RebuildCache()
{
EditorApplication.update -= RebuildCache;

if (EditorApplication.isPlaying && EditorApplication.isPaused)
return; // Use the cached data that should have been passed in the play state change.

LoaderAssignmentRequests reqs = GetAllRequestsInQueue(k_RebuildCache);

if (reqs.activeRequests == null || reqs.activeRequests.Count == 0)
return;

var req = reqs.activeRequests[0];

if (!req.rebuildRequestOnly && IsPackageInstalled(req.packageId))
{
reqs.activeRequests.Remove(req);
req.installationState = InstallationState.Assigning;
QueueLoaderRequest(req);
}
else if (req.packageListRequest.IsCompleted)
{
reqs.activeRequests.Remove(req);

if (req.packageListRequest.Status == StatusCode.Success)
{
s_InstalledPackages.Clear();

List<string> installedPackages = new List<string>();

foreach (var packageInfo in req.packageListRequest.Result)
{
installedPackages.Add(packageInfo.name);
}

foreach (var p in s_Packages.Values)
{
if (installedPackages.Contains(p.metadata.packageId))
{
s_InstalledPackages.Add(p.metadata.packageId);
}
}

if (!req.rebuildRequestOnly)
{
if (IsPackageInstalled(req.packageId))
{
req.installationState = InstallationState.Assigning;
}
else
{
req.installationState = InstallationState.StartInstallation;
}
QueueLoaderRequest(req);
}
}
else
{
req.errorText = $"Error installing package {req.packageId}. Error Code: {req.packageListRequest.Status} Error Message: {req.packageListRequest.Error.message}";
req.installationState = InstallationState.Error;
QueueLoaderRequest(req);
}

}

if (reqs.activeRequests.Count > 0)
{
SetRequestsInQueue(reqs, k_RebuildCache);
EditorApplication.update += RebuildCache;
}

}

private static void AssignAnyRequestedLoadersUpdate()
{
EditorApplication.update -= AssignAnyRequestedLoadersUpdate;
Expand Down Expand Up @@ -351,17 +449,19 @@ internal static void MoveMockInListToEnd(List<LoaderBuildTargetQueryResult> load
}
}

internal static List<LoaderBuildTargetQueryResult> GetAllLoaders()
internal static List<LoaderBuildTargetQueryResult> GetAllLoadersForBuildTarget(BuildTargetGroup buildTarget)
{
var ret = from pm in (from p in s_Packages.Values select p.metadata)
from lm in pm.loaderMetadata
where lm.supportedBuildTargets.Contains(buildTarget)
orderby lm.loaderName
select new LoaderBuildTargetQueryResult() { packageName = pm.packageName, packageId = pm.packageId, loaderName = lm.loaderName, loaderType = lm.loaderType };
var retList = ret.Distinct().ToList<LoaderBuildTargetQueryResult>();
MoveMockInListToEnd(retList);
return retList;
}


internal static List<LoaderBuildTargetQueryResult> GetLoadersForBuildTarget(BuildTargetGroup buildTargetGroup)
{
var ret = from pm in (from p in s_Packages.Values select p.metadata)
Expand Down Expand Up @@ -389,38 +489,6 @@ internal static IXRPackageMetadata GetMetadataForPackage(string packageId)
return ret;
}

internal static void RebuildInstalledCache()
{
var listRequest = Client.List(true, false);

var listWaitLimit = 0;
while (!listRequest.IsCompleted && listWaitLimit < 500)
{
listWaitLimit++;
Thread.Sleep(10);
}

if (listRequest.IsCompleted && listRequest.Status == StatusCode.Success)
{
s_InstalledPackages.Clear();

List<string> installedPackages = new List<string>();

foreach (var packageInfo in listRequest.Result)
{
installedPackages.Add(packageInfo.name);
}

foreach (var p in s_Packages.Values)
{
if (installedPackages.Contains(p.metadata.packageId))
{
s_InstalledPackages.Add(p.metadata.packageId);
}
}
}
}

internal static bool HasInstallablePackageData()
{
return s_InstallablePackages.Any();
Expand Down Expand Up @@ -482,14 +550,20 @@ private static void MonitorPackageInstallation()
}
else
{
request.errorText = $"Error installing package {request.packageId}. Error Code: {request.packageAddRequest.Status}";
request.errorText = $"Error installing package {request.packageId}. Error Code: {request.packageAddRequest.Status} Error Message: {request.packageAddRequest.Error.message}";
request.installationState = InstallationState.Error;
QueueLoaderRequest(request);
}
}
else if (request.timeOut < Time.realtimeSinceStartup)
{
request.errorText = $"Error installing package {request.packageId}. Package installation timed out. Check Package Manager UI to see if the package is installed and/or retry your operation.";

if (request.packageAddRequest.IsCompleted)
{
request.errorText += $" Error message: {request.packageAddRequest.Error.message}";
}

request.installationState = InstallationState.Error;
QueueLoaderRequest(request);
}
Expand All @@ -515,7 +589,7 @@ private static void WaitingOnSearchQuery()
for (int i = 0; i < reqs.activeRequests.Count; i++)
{
var req = reqs.activeRequests[i];
req.installationState = InstallationState.StartInstallation;
req.installationState = InstallationState.RebuildInstalledCache;
QueueLoaderRequest(req);
}
}
Expand Down Expand Up @@ -557,6 +631,12 @@ private static void QueueLoaderRequest(LoaderAssignmentRequest req)
EditorApplication.update += WaitingOnSearchQuery;
break;

case InstallationState.RebuildInstalledCache:
req.packageListRequest = Client.List(true, false);
AddRequestToQueue(req, k_RebuildCache);
EditorApplication.update += RebuildCache;
break;

case InstallationState.StartInstallation:
req.needsAddRequest = true;
req.packageAddRequest = null;
Expand Down Expand Up @@ -638,7 +718,7 @@ public static bool AssignLoader(XRManagerSettings settings, string loaderTypeNam
assignedLoaders.Add(newLoader);
settings.loaders = new List<XRLoader>();

var allLoaders = GetAllLoaders();
var allLoaders = GetAllLoadersForBuildTarget(buildTargetGroup);

foreach (var ldr in allLoaders)
{
Expand Down Expand Up @@ -706,7 +786,11 @@ internal static void ReportProgressOnActiveWork()
{
if (XRPackageMetadataStore.isCheckingInstallationRequirements)
{
EditorUtility.DisplayProgressBar("XR Management", "Checking installation requirements for packages...", 0.5f);
EditorUtility.DisplayProgressBar("XR Management", "Checking installation requirements for packages...", 0.2f);
}
else if (XRPackageMetadataStore.isRebuildingCache)
{
EditorUtility.DisplayProgressBar("XR Management", "Rebuilding package cache...", 0.4f);
}
else if (XRPackageMetadataStore.isInstallingPackages)
{
Expand All @@ -718,7 +802,7 @@ internal static void ReportProgressOnActiveWork()
}
else if (XRPackageMetadataStore.isAssigningLoaders)
{
EditorUtility.DisplayProgressBar("XR Management", "Assigning all requested loaders...", 0.5f);
EditorUtility.DisplayProgressBar("XR Management", "Assigning all requested loaders...", 0.8f);
}
else
{
Expand Down
15 changes: 0 additions & 15 deletions Editor/XRGeneralSettingsPerBuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ static void BeginUpgradeSettings()
static XRGeneralSettingsPerBuildTarget()
{
EditorApplication.playModeStateChanged += PlayModeStateChanged;
EditorApplication.pauseStateChanged += PauseStateChange;
}

void OnEnable()
Expand Down Expand Up @@ -84,20 +83,6 @@ static void PlayModeStateChanged(PlayModeStateChange state)
instance.InternalPlayModeStateChanged(state);
}

static void PauseStateChange(PauseState state)
{
XRGeneralSettingsPerBuildTarget buildTargetSettings = null;
EditorBuildSettings.TryGetConfigObject(XRGeneralSettings.k_SettingsKey, out buildTargetSettings);
if (buildTargetSettings == null)
return;

XRGeneralSettings instance = buildTargetSettings.SettingsForBuildTarget(BuildTargetGroup.Standalone);
if (instance == null || !instance.InitManagerOnStart)
return;

instance.InternalPauseStateChanged(state);
}

internal static bool ContainsLoaderForAnyBuildTarget(string loaderTypeName)
{

Expand Down
9 changes: 1 addition & 8 deletions Editor/XRLoaderOrderUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,7 @@ internal bool OnGUI(BuildTargetGroup buildTargetGroup)
{
if (li.toggled)
{
if (XRPackageMetadataStore.IsPackageInstalled(li.packageId))
{
XRPackageMetadataStore.AssignLoader(settings.AssignedSettings, li.loaderType, buildTargetGroup);
}
else
{
XRPackageMetadataStore.InstallPackageAndAssignLoaderForBuildTarget(li.packageId, li.loaderType, buildTargetGroup);
}
XRPackageMetadataStore.InstallPackageAndAssignLoaderForBuildTarget(li.packageId, li.loaderType, buildTargetGroup);
}
else
{
Expand Down
Loading

0 comments on commit 0489230

Please sign in to comment.