Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: asset bundle fallback #3008

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ public enum DecentralandUrl
CameraReelImages,
CameraReelPlaces,
CameraReelLink,
AssetBundleRegistry

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private static string RawUrl(DecentralandUrl decentralandUrl) =>
DecentralandUrl.CameraReelImages => $"https://camera-reel-service.decentraland.{ENV}/api/images",
DecentralandUrl.CameraReelPlaces => $"https://camera-reel-service.decentraland.{ENV}/api/places",
DecentralandUrl.CameraReelLink => $"https://reels.decentraland.{ENV}",
DecentralandUrl.AssetBundleRegistry => $"https://asset-bundle-registry.decentraland.{ENV}",
_ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null!)
};
}
Expand Down
1 change: 1 addition & 0 deletions Explorer/Assets/DCL/FeatureFlags/FeatureFlagsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static class FeatureFlagsStrings
public const string SKYBOX_SETTINGS = "alfa-skybox-settings";
public const string SKYBOX_SETTINGS_VARIANT = "settings";
public const string VIDEO_PRIORITIZATION = "alfa-video-prioritization";
public const string ASSET_BUNDLE_FALLBACK = "alfa-asset-bundle-fallback";

public const string CAMERA_REEL = "alpha-camera-reel";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using DCL.Browser.DecentralandUrls;
using DCL.Multiplayer.Connections.DecentralandUrls;
using UnityEngine;
using Utility;

Expand Down Expand Up @@ -72,6 +74,7 @@ private SelfProfile CreateProfile()
web3IdentityCache,
IWebRequestController.DEFAULT,
URLDomain.FromString("TestRealm"),
URLDomain.EMPTY,
new ServerAbout(
lambdas: new ContentEndpoint(profileUrl)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"GUID:e169fa6683c924c7e99a85981a91d953",
"GUID:9ca29a7d75ab84bab806a20bbd350fd8",
"GUID:029c1c1b674aaae47a6841a0b89ad80e",
"GUID:e7751264a6735a942a64770d71eb49e0"
"GUID:e7751264a6735a942a64770d71eb49e0",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
4 changes: 3 additions & 1 deletion Explorer/Assets/DCL/Ipfs/DCL.Ipfs.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:5ab29fa8ae5769b49ab29e390caca7a4",
"GUID:4a12c0b1b77ec6b418a8d7bd5c925be3",
"GUID:166b65e6dfc848bb9fb075f53c293a38"
"GUID:166b65e6dfc848bb9fb075f53c293a38",
"GUID:91cf8206af184dac8e30eb46747e9939",
"GUID:ace653ac543d483ba8abee112a3ba2a6"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
1 change: 1 addition & 0 deletions Explorer/Assets/DCL/Ipfs/IIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IIpfsRealm
public URLDomain LambdasBaseUrl { get; }
public IReadOnlyList<string> SceneUrns { get; }
public URLDomain EntitiesActiveEndpoint { get; }
public URLDomain AssetBundleRegistry { get; }

UniTask PublishAsync<T>(EntityDefinitionGeneric<T> entity, CancellationToken ct, IReadOnlyDictionary<string, byte[]>? contentFiles = null);

Expand Down
1 change: 1 addition & 0 deletions Explorer/Assets/DCL/Ipfs/InvalidIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static InvalidIpfsRealm Instance
public URLDomain LambdasBaseUrl => URLDomain.EMPTY;
public IReadOnlyList<string> SceneUrns { get; } = new List<string>();
public URLDomain EntitiesActiveEndpoint => URLDomain.EMPTY;
public URLDomain AssetBundleRegistry => URLDomain.EMPTY;

public UniTask PublishAsync<T>(EntityDefinitionGeneric<T> entity, CancellationToken ct, IReadOnlyDictionary<string, byte[]>? contentFiles = null) =>
throw new NotSupportedException();
Expand Down
8 changes: 7 additions & 1 deletion Explorer/Assets/DCL/Ipfs/IpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ public class IpfsRealm : IIpfsRealm, IEquatable<IpfsRealm>
public URLDomain ContentBaseUrl { get; }
public URLDomain LambdasBaseUrl { get; }
public URLDomain EntitiesActiveEndpoint { get; }
public URLDomain AssetBundleRegistry { get; }

public IReadOnlyList<string> SceneUrns => sceneUrns;

public IpfsRealm(IWeb3IdentityCache web3IdentityCache,
IWebRequestController webRequestController,
URLDomain realmName, ServerAbout? serverAbout = null)
URLDomain realmName,
URLDomain assetBundleRegistry,
ServerAbout? serverAbout = null)
{
this.web3IdentityCache = web3IdentityCache;
this.webRequestController = webRequestController;
Expand All @@ -48,13 +51,16 @@ public IpfsRealm(IWeb3IdentityCache web3IdentityCache,
//Note: Content url requires the subdirectory content, but the actives endpoint requires the base one.
EntitiesActiveEndpoint = URLBuilder.Combine(ContentBaseUrl, URLSubdirectory.FromString("entities/active"));
ContentBaseUrl = URLBuilder.Combine(ContentBaseUrl, URLSubdirectory.FromString("contents/"));

AssetBundleRegistry = assetBundleRegistry.IsEmpty ? EntitiesActiveEndpoint : assetBundleRegistry;
}
else
{
sceneUrns = new List<string>();
entitiesBaseUrl = URLBuilder.Combine(CatalystBaseUrl, URLSubdirectory.FromString("content/entities/"));
ContentBaseUrl = URLBuilder.Combine(CatalystBaseUrl, URLSubdirectory.FromString("content/contents/"));
EntitiesActiveEndpoint = URLBuilder.Combine(CatalystBaseUrl, URLSubdirectory.FromString("content/entities/active"));
AssetBundleRegistry = assetBundleRegistry.IsEmpty ? EntitiesActiveEndpoint : assetBundleRegistry;
}
}

Expand Down
2 changes: 2 additions & 0 deletions Explorer/Assets/DCL/Ipfs/LocalIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public class LocalIpfsRealm : IIpfsRealm
public URLDomain LambdasBaseUrl { get; }
public IReadOnlyList<string> SceneUrns => Array.Empty<string>();
public URLDomain EntitiesActiveEndpoint => URLDomain.EMPTY;
public URLDomain AssetBundleRegistry { get; }

public LocalIpfsRealm(URLDomain fullPath)
{
CatalystBaseUrl = fullPath;
ContentBaseUrl = fullPath;
AssetBundleRegistry = fullPath;
LambdasBaseUrl = URLDomain.FromString("https://peer.decentraland.org/explorer/");
}

Expand Down
12 changes: 12 additions & 0 deletions Explorer/Assets/DCL/Ipfs/LogIpfsRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ public URLDomain EntitiesActiveEndpoint
}
}

public URLDomain AssetBundleRegistry
{
get
{
var result = origin.AssetBundleRegistry;
ReportHub
.WithReport(ReportCategory.REALM)
.Log($"IpfsRealm AssetBundleRegistry requested, result: {result}");
return result;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property getters should not have side effects. The log message suggests that there are side effects.


public async UniTask PublishAsync<T>(EntityDefinitionGeneric<T> entity, CancellationToken ct, IReadOnlyDictionary<string, byte[]>? contentFiles = null)
{
var sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public async UniTask<MetaData> MetaDataAsync(MetaData.Input input, CancellationT
// TODO: instead of making a new request, Room Change request should be initiated when the scene definition is loaded by ECS,
// currently these processes are completely separated
var promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(world,
new GetSceneDefinitionList(entityDefinitionList, pointersList, new CommonLoadingArguments(realmData.Ipfs.EntitiesActiveEndpoint)),
new GetSceneDefinitionList(entityDefinitionList, pointersList,
new CommonLoadingArguments(realmData.Ipfs.AssetBundleRegistry)),
PartitionComponent.TOP_PRIORITY);

promise = await promise.ToUniTaskAsync(world, cancellationToken: token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public RetrieveSceneFromVolatileWorld(IRealmData realmData)
pointersList.Value.Add(parcel.ToInt2());

var promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(World,
new GetSceneDefinitionList(targetCollection.Value, pointersList.Value, new CommonLoadingArguments(realmIpfs.EntitiesActiveEndpoint)),
new GetSceneDefinitionList(targetCollection.Value, pointersList.Value,
new CommonLoadingArguments(realmIpfs.AssetBundleRegistry)),
PartitionComponent.TOP_PRIORITY);

promise = await promise.ToUniTaskAsync(World, cancellationToken: ct);
Expand Down
3 changes: 2 additions & 1 deletion Explorer/Assets/DCL/Profiles/DCL.Profiles.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"GUID:166b65e6dfc848bb9fb075f53c293a38",
"GUID:3c7b57a14671040bd8c549056adc04f5",
"GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b",
"GUID:543b8f091a5947a3880b7f2bca2358bd"
"GUID:543b8f091a5947a3880b7f2bca2358bd",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using ECS;
using System.Collections.Generic;
using System.Threading;
using DCL.Browser.DecentralandUrls;
using DCL.Multiplayer.Connections.DecentralandUrls;
using UnityEngine;

namespace DCL.Profiles.Self.Playground
Expand Down Expand Up @@ -39,6 +41,7 @@ private async UniTaskVoid ExecuteAsync(CancellationToken ct)
web3IdentityCache,
IWebRequestController.DEFAULT,
URLDomain.FromString(url),
URLDomain.EMPTY,
new ServerAbout(
lambdas: new ContentEndpoint(url)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void StartLoadingFromVolatilePointers(ref RealmComponent realm, ref Vola
volatileScenePointers.ActivePromise
= AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(World,
new GetSceneDefinitionList(volatileScenePointers.RetrievedReusableList, input,
new CommonLoadingArguments(realm.Ipfs.EntitiesActiveEndpoint)),
new CommonLoadingArguments(realm.Ipfs.AssetBundleRegistry)),
volatileScenePointers.ActivePartitionComponent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void ResolvePromise(ref RealmComponent realm, ref StaticScenePointers st
// start loading
staticScenePointers.Promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(World,
new GetSceneDefinitionList(new List<SceneEntityDefinition>(staticScenePointers.Value.Count), staticScenePointers.Value,
new CommonLoadingArguments(realm.Ipfs.EntitiesActiveEndpoint)), PartitionComponent.TOP_PRIORITY);
new CommonLoadingArguments(realm.Ipfs.AssetBundleRegistry)), PartitionComponent.TOP_PRIORITY);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TestIpfsRealm : IIpfsRealm
public URLDomain LambdasBaseUrl { get; }
public IReadOnlyList<string> SceneUrns { get; }
public URLDomain EntitiesActiveEndpoint { get; }
public URLDomain AssetBundleRegistry { get; }

public URLDomain CatalystBaseUrl { get; }
public URLDomain ContentBaseUrl { get; }
Expand All @@ -24,6 +25,7 @@ public TestIpfsRealm(string[] sceneUrns = null)
CatalystBaseUrl = URLDomain.FromString($"file://{Application.dataPath + "/../TestResources/"}");
ContentBaseUrl = CatalystBaseUrl.Append(URLSubdirectory.FromString("Content/"));
EntitiesActiveEndpoint = URLDomain.FromString($"{ContentBaseUrl.Value}ActiveEntitiesByPointer.json");
AssetBundleRegistry = URLDomain.FromString($"{ContentBaseUrl.Value}ActiveEntitiesByPointer.json");
LambdasBaseUrl = URLDomain.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ IMultiPool MultiPoolFactory() =>
debugBuilder,
staticContainer.ComponentsContainer.ComponentPoolsRegistry
.GetReferenceTypePool<PartitionComponent>(),
localSceneDevelopment);
localSceneDevelopment,
bootstrapContainer.DecentralandUrlsSource,
staticContainer.FeatureFlagsCache);

container.reloadSceneController = new ECSReloadScene(staticContainer.ScenesCache, globalWorld, playerEntity, localSceneDevelopment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using ECS.LifeCycle.Components;
using SceneRunner.Scene;
using System.Linq;
using DCL.Multiplayer.Connections.DecentralandUrls;

namespace PortableExperiences.Controller
{
Expand All @@ -28,6 +29,7 @@ public class ECSPortableExperiencesController : IPortableExperiencesController
private readonly World globalWorld;
private readonly List<IPortableExperiencesController.SpawnResponse> spawnResponsesList = new ();
private readonly FeatureFlagsCache featureFlagsCache;
private readonly IDecentralandUrlsSource urlsSources;
public Dictionary<ENS, Entity> PortableExperienceEntities { get; } = new ();


Expand All @@ -36,13 +38,15 @@ public ECSPortableExperiencesController(
IWeb3IdentityCache web3IdentityCache,
IWebRequestController webRequestController,
IScenesCache scenesCache,
FeatureFlagsCache featureFlagsCache)
FeatureFlagsCache featureFlagsCache,
IDecentralandUrlsSource urlsSources)
{
this.globalWorld = globalWorld;
this.web3IdentityCache = web3IdentityCache;
this.webRequestController = webRequestController;
this.scenesCache = scenesCache;
this.featureFlagsCache = featureFlagsCache;
this.urlsSources = urlsSources;
}

public async UniTask<IPortableExperiencesController.SpawnResponse> CreatePortableExperienceByEnsAsync(ENS ens, CancellationToken ct, bool isGlobalPortableExperience = false, bool force = false)
Expand Down Expand Up @@ -82,9 +86,16 @@ public ECSPortableExperiencesController(
throw new Exception($"Scene not Available in provided Portable Experience with ens: {ens}");
}

var assetBundleRegistry =
featureFlagsCache.Configuration.IsEnabled(FeatureFlagsStrings.ASSET_BUNDLE_FALLBACK)
? URLBuilder.Combine(URLDomain.FromString(urlsSources.Url(DecentralandUrl.AssetBundleRegistry)),
URLSubdirectory.FromString("entities/active"))
: URLDomain.EMPTY;

var realmData = new RealmData();
realmData.Reconfigure(
new IpfsRealm(web3IdentityCache, webRequestController, portableExperiencePath, result),
new IpfsRealm(web3IdentityCache, webRequestController, portableExperiencePath, assetBundleRegistry,
result),
result.configurations.realmName.EnsureNotNull("Realm name not found"),
result.configurations.networkId,
result.comms?.adapter ?? string.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"GUID:101b8b6ebaf64668909b49c4b7a1420d",
"GUID:1b8e1e1bd01505f478f0369c04a4fb2f",
"GUID:ace653ac543d483ba8abee112a3ba2a6",
"GUID:3640f3c0b42946b0b8794a1ed8e06ca5"
"GUID:3640f3c0b42946b0b8794a1ed8e06ca5",
"GUID:91cf8206af184dac8e30eb46747e9939"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
22 changes: 18 additions & 4 deletions Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using System.Collections.Generic;
using System.Threading;
using DCL.DebugUtilities;
using DCL.FeatureFlags;
using DCL.Multiplayer.Connections.DecentralandUrls;
using ECS.SceneLifeCycle.Realm;
using Unity.Mathematics;

Expand All @@ -49,13 +51,15 @@ public class RealmController : IGlobalRealmController
private readonly SceneAssetLock sceneAssetLock;
private readonly IComponentPool<PartitionComponent> partitionComponentPool;
private readonly bool isLocalSceneDevelopment;
private readonly IDecentralandUrlsSource urlsSource;

private GlobalWorld? globalWorld;
private Entity realmEntity;

public IRealmData RealmData => realmData;

private readonly RealmNavigatorDebugView realmNavigatorDebugView;
private readonly FeatureFlagsCache featureFlagsCache;

public RealmType Type
{
Expand Down Expand Up @@ -95,8 +99,9 @@ public RealmController(
SceneAssetLock sceneAssetLock,
IDebugContainerBuilder debugContainerBuilder,
IComponentPool<PartitionComponent> partitionComponentPool,
bool isLocalSceneDevelopment
)
bool isLocalSceneDevelopment,
IDecentralandUrlsSource urlsSource,
FeatureFlagsCache featureFlagsCache)
{
this.web3IdentityCache = web3IdentityCache;
this.webRequestController = webRequestController;
Expand All @@ -110,6 +115,8 @@ bool isLocalSceneDevelopment
this.sceneAssetLock = sceneAssetLock;
this.partitionComponentPool = partitionComponentPool;
this.isLocalSceneDevelopment = isLocalSceneDevelopment;
this.urlsSource = urlsSource;
this.featureFlagsCache = featureFlagsCache;
realmNavigatorDebugView = new RealmNavigatorDebugView(debugContainerBuilder);
}

Expand All @@ -129,8 +136,15 @@ public async UniTask SetRealmAsync(URLDomain realm, CancellationToken ct)

string hostname = ResolveHostname(realm, result);


var assetBundleRegistry =
featureFlagsCache.Configuration.IsEnabled(FeatureFlagsStrings.ASSET_BUNDLE_FALLBACK)
? URLBuilder.Combine(URLDomain.FromString(urlsSource.Url(DecentralandUrl.AssetBundleRegistry)),
URLSubdirectory.FromString("entities/active"))
: URLDomain.EMPTY;

realmData.Reconfigure(
new IpfsRealm(web3IdentityCache, webRequestController, realm, result),
new IpfsRealm(web3IdentityCache, webRequestController, realm, assetBundleRegistry, result),
result.configurations.realmName.EnsureNotNull("Realm name not found"),
result.configurations.networkId,
result.comms?.adapter ?? result.comms?.fixedAdapter ?? "offline:offline", //"offline property like in previous implementation"
Expand Down Expand Up @@ -185,7 +199,7 @@ await UniTask.WaitUntil(() => GlobalWorld.EcsWorld.TryGet(realmEntity, out fixed

var promise = AssetPromise<SceneDefinitions, GetSceneDefinitionList>.Create(GlobalWorld.EcsWorld,
new GetSceneDefinitionList(new List<SceneEntityDefinition>(staticLoadPositions.Count), staticLoadPositions,
new CommonLoadingArguments(RealmData.Ipfs.EntitiesActiveEndpoint)), PartitionComponent.TOP_PRIORITY);
new CommonLoadingArguments(RealmData.Ipfs.AssetBundleRegistry)), PartitionComponent.TOP_PRIORITY);

promise = await promise.ToUniTaskAsync(GlobalWorld.EcsWorld, cancellationToken: ct);

Expand Down
4 changes: 3 additions & 1 deletion Explorer/Assets/Scripts/Global/StaticContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ await UniTask.WhenAll(

container.PhysicsTickProvider = new PhysicsTickProvider();
container.FeatureFlagsCache = new FeatureFlagsCache();
container.PortableExperiencesController = new ECSPortableExperiencesController(globalWorld, web3IdentityProvider, container.WebRequestsContainer.WebRequestController, container.ScenesCache, container.FeatureFlagsCache);
container.PortableExperiencesController = new ECSPortableExperiencesController(globalWorld,
web3IdentityProvider, container.WebRequestsContainer.WebRequestController, container.ScenesCache,
container.FeatureFlagsCache, decentralandUrlsSource);

container.FeatureFlagsProvider = new HttpFeatureFlagsProvider(container.WebRequestsContainer.WebRequestController,
container.FeatureFlagsCache);
Expand Down
Loading