mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-02 10:50:11 +00:00
Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning. Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called. The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range. All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out. * Add imports * Fix build failure * Encapsulate common logics into methods * Address comments
45 lines
2.1 KiB
Objective-C
45 lines
2.1 KiB
Objective-C
//
|
|
// ASExperimentalFeatures.h
|
|
// Texture
|
|
//
|
|
// Copyright (c) Pinterest, Inc. All rights reserved.
|
|
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <AsyncDisplayKit/ASAvailability.h>
|
|
#import <AsyncDisplayKit/ASBaseDefines.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/**
|
|
* A bit mask of features. Make sure to update configuration.json when you add entries.
|
|
*/
|
|
typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
|
|
ASExperimentalGraphicsContexts = 1 << 0, // exp_graphics_contexts
|
|
// If AS_ENABLE_TEXTNODE=0 or TextNode2 subspec is used this setting is a no op and ASTextNode2
|
|
// will be used in all cases
|
|
ASExperimentalTextNode = 1 << 1, // exp_text_node
|
|
ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce
|
|
ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock
|
|
ASExperimentalLayerDefaults = 1 << 4, // exp_infer_layer_defaults
|
|
ASExperimentalCollectionTeardown = 1 << 5, // exp_collection_teardown
|
|
ASExperimentalFramesetterCache = 1 << 6, // exp_framesetter_cache
|
|
ASExperimentalSkipClearData = 1 << 7, // exp_skip_clear_data
|
|
ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 8, // exp_did_enter_preload_skip_asm_layout
|
|
ASExperimentalDisableAccessibilityCache = 1 << 9, // exp_disable_a11y_cache
|
|
ASExperimentalSkipAccessibilityWait = 1 << 10, // exp_skip_a11y_wait
|
|
ASExperimentalNewDefaultCellLayoutMode = 1 << 11, // exp_new_default_cell_layout_mode
|
|
ASExperimentalDispatchApply = 1 << 12, // exp_dispatch_apply
|
|
ASExperimentalImageDownloaderPriority = 1 << 13, // exp_image_downloader_priority
|
|
ASExperimentalFeatureAll = 0xFFFFFFFF
|
|
};
|
|
|
|
/// Convert flags -> name array.
|
|
AS_EXTERN NSArray<NSString *> *ASExperimentalFeaturesGetNames(ASExperimentalFeatures flags);
|
|
|
|
/// Convert name array -> flags.
|
|
AS_EXTERN ASExperimentalFeatures ASExperimentalFeaturesFromArray(NSArray<NSString *> *array);
|
|
|
|
NS_ASSUME_NONNULL_END
|