Skip to content

Commit eb53d64

Browse files
Loosen client-side media processing requirements
Lower CPU core requirement from 4 to 2 and allow 3g network connections. This widens feature availability to more devices per feedback in #74333.
1 parent 0bcb0ca commit eb53d64

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎packages/upload-media/src/feature-detection.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ let cachedResult: FeatureDetectionResult | null = null;
3535
* 2. SharedArrayBuffer support (required for WASM threading)
3636
* 3. CSP compatibility for blob URL workers (required for inline worker creation)
3737
* 4. Device memory (disables on devices with ≤2 GB RAM)
38-
* 5. Hardware concurrency (disables on devices with fewer than 4 CPU cores)
39-
* 6. Network conditions (disables when data saver / reduced data mode is on or connection is 3g/2g/slow-2g)
38+
* 5. Hardware concurrency (disables on devices with fewer than 2 CPU cores)
39+
* 6. Network conditions (disables when data saver / reduced data mode is on or connection is 2g/slow-2g)
4040
* 7. Web Worker support (baseline requirement)
4141
*
4242
* Results are cached after the first call. Use `clearFeatureDetectionCache()` to reset.
@@ -93,7 +93,7 @@ export function detectClientSideMediaSupport(): FeatureDetectionResult {
9393
if (
9494
typeof navigator !== 'undefined' &&
9595
'hardwareConcurrency' in navigator &&
96-
navigator.hardwareConcurrency < 4
96+
navigator.hardwareConcurrency < 2
9797
) {
9898
cachedResult = {
9999
supported: false,
@@ -115,8 +115,7 @@ export function detectClientSideMediaSupport(): FeatureDetectionResult {
115115
}
116116
if (
117117
connection.effectiveType === 'slow-2g' ||
118-
connection.effectiveType === '2g' ||
119-
connection.effectiveType === '3g'
118+
connection.effectiveType === '2g'
120119
) {
121120
cachedResult = {
122121
supported: false,

‎packages/upload-media/src/test/feature-detection.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ describe( 'feature-detection', () => {
171171
expect( result.supported ).toBe( true );
172172
} );
173173

174-
it( 'returns not supported when hardware concurrency is less than 4', () => {
174+
it( 'returns not supported when hardware concurrency is less than 2', () => {
175175
Object.defineProperty( navigator, 'hardwareConcurrency', {
176-
value: 2,
176+
value: 1,
177177
configurable: true,
178178
} );
179179

@@ -183,9 +183,9 @@ describe( 'feature-detection', () => {
183183
expect( result.reason ).toContain( 'insufficient CPU cores' );
184184
} );
185185

186-
it( 'returns supported when hardware concurrency is 4 or more', () => {
186+
it( 'returns supported when hardware concurrency is 2 or more', () => {
187187
Object.defineProperty( navigator, 'hardwareConcurrency', {
188-
value: 4,
188+
value: 2,
189189
configurable: true,
190190
} );
191191

@@ -218,16 +218,15 @@ describe( 'feature-detection', () => {
218218
expect( result.reason ).toContain( 'too slow' );
219219
} );
220220

221-
it( 'returns not supported when connection is 3g', () => {
221+
it( 'returns supported when connection is 3g', () => {
222222
Object.defineProperty( navigator, 'connection', {
223223
value: { saveData: false, effectiveType: '3g' },
224224
configurable: true,
225225
} );
226226

227227
const result = detectClientSideMediaSupport();
228228

229-
expect( result.supported ).toBe( false );
230-
expect( result.reason ).toContain( 'too slow' );
229+
expect( result.supported ).toBe( true );
231230
} );
232231

233232
it( 'returns not supported when connection is slow-2g', () => {

0 commit comments

Comments
 (0)