Skip to content

Commit 05baf62

Browse files
zeyadsalloumfacebook-github-bot
authored andcommitted
Revert D15237418: [react-native][PR] [Blob] Release underlying resources when JS instance in GC'ed on iOS
Differential Revision: D15237418 Original commit changeset: 00a94a54b0b1 fbshipit-source-id: bb6c7aa3f5b6ae7f40965b96f1e0fd8eb7512015
1 parent fdd8fad commit 05baf62

File tree

6 files changed

+2
-130
lines changed

6 files changed

+2
-130
lines changed

Libraries/Blob/BlobManager.js

+2-28
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Blob = require('Blob');
1414
const BlobRegistry = require('BlobRegistry');
1515
const {BlobModule} = require('NativeModules');
1616

17-
import type {BlobData, BlobOptions, BlobCollector} from 'BlobTypes';
17+
import type {BlobData, BlobOptions} from 'BlobTypes';
1818

1919
/*eslint-disable no-bitwise */
2020
/*eslint-disable eqeqeq */
@@ -31,21 +31,6 @@ function uuidv4(): string {
3131
});
3232
}
3333

34-
// **Temporary workaround**
35-
// TODO(#24654): Use turbomodules for the Blob module.
36-
// Blob collector is a jsi::HostObject that is used by native to know
37-
// when the a Blob instance is deallocated. This allows to free the
38-
// underlying native resources. This is a hack to workaround the fact
39-
// that the current bridge infra doesn't allow to track js objects
40-
// deallocation. Ideally the whole Blob object should be a jsi::HostObject.
41-
function createBlobCollector(blobId: string): BlobCollector | null {
42-
if (global.__blobCollectorProvider == null) {
43-
return null;
44-
} else {
45-
return global.__blobCollectorProvider(blobId);
46-
}
47-
}
48-
4934
/**
5035
* Module to manage blobs. Wrapper around the native blob module.
5136
*/
@@ -109,18 +94,7 @@ class BlobManager {
10994
*/
11095
static createFromOptions(options: BlobData): Blob {
11196
BlobRegistry.register(options.blobId);
112-
return Object.assign(Object.create(Blob.prototype), {
113-
data:
114-
// Reuse the collector instance when creating from an existing blob.
115-
// This will make sure that the underlying resource is only deallocated
116-
// when all blobs that refer to it are deallocated.
117-
options.__collector == null
118-
? {
119-
...options,
120-
__collector: createBlobCollector(options.blobId),
121-
}
122-
: options,
123-
});
97+
return Object.assign(Object.create(Blob.prototype), {data: options});
12498
}
12599

126100
/**

Libraries/Blob/BlobTypes.js

-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010

1111
'use strict';
1212

13-
export opaque type BlobCollector = {};
14-
1513
export type BlobData = {
1614
blobId: string,
1715
offset: number,
1816
size: number,
1917
name?: string,
2018
type?: string,
2119
lastModified?: number,
22-
__collector?: ?BlobCollector,
2320
};
2421

2522
export type BlobOptions = {

Libraries/Blob/RCTBlob.xcodeproj/project.pbxproj

-13
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
1946172A225F085900E4E008 /* RCTBlobCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 19461728225F085900E4E008 /* RCTBlobCollector.h */; };
11-
1946172B225F085900E4E008 /* RCTBlobCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 19461728225F085900E4E008 /* RCTBlobCollector.h */; };
12-
1946172C225F085900E4E008 /* RCTBlobCollector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 19461729225F085900E4E008 /* RCTBlobCollector.mm */; };
13-
1946172D225F085900E4E008 /* RCTBlobCollector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 19461729225F085900E4E008 /* RCTBlobCollector.mm */; };
1410
19BA88FE1F84391700741C5A /* RCTFileReaderModule.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = ADDFBA6A1F33455F0064C998 /* RCTFileReaderModule.h */; };
1511
19BA88FF1F84392900741C5A /* RCTFileReaderModule.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDFBA6A1F33455F0064C998 /* RCTFileReaderModule.h */; };
1612
19BA89001F84392F00741C5A /* RCTFileReaderModule.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = ADDFBA6A1F33455F0064C998 /* RCTFileReaderModule.h */; };
@@ -53,8 +49,6 @@
5349
/* End PBXCopyFilesBuildPhase section */
5450

5551
/* Begin PBXFileReference section */
56-
19461728225F085900E4E008 /* RCTBlobCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTBlobCollector.h; sourceTree = "<group>"; };
57-
19461729225F085900E4E008 /* RCTBlobCollector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTBlobCollector.mm; sourceTree = "<group>"; };
5852
358F4ED71D1E81A9004DF814 /* libRCTBlob.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTBlob.a; sourceTree = BUILT_PRODUCTS_DIR; };
5953
AD9A43C11DFC7126008DC588 /* RCTBlobManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTBlobManager.h; sourceTree = "<group>"; };
6054
AD9A43C21DFC7126008DC588 /* RCTBlobManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTBlobManager.mm; sourceTree = "<group>"; };
@@ -67,8 +61,6 @@
6761
358F4ECE1D1E81A9004DF814 = {
6862
isa = PBXGroup;
6963
children = (
70-
19461728225F085900E4E008 /* RCTBlobCollector.h */,
71-
19461729225F085900E4E008 /* RCTBlobCollector.mm */,
7264
ADDFBA6A1F33455F0064C998 /* RCTFileReaderModule.h */,
7365
ADDFBA6B1F33455F0064C998 /* RCTFileReaderModule.m */,
7466
AD9A43C11DFC7126008DC588 /* RCTBlobManager.h */,
@@ -97,7 +89,6 @@
9789
buildActionMask = 2147483647;
9890
files = (
9991
AD0871161E215EC9007D136D /* RCTBlobManager.h in Headers */,
100-
1946172A225F085900E4E008 /* RCTBlobCollector.h in Headers */,
10192
ADDFBA6C1F33455F0064C998 /* RCTFileReaderModule.h in Headers */,
10293
);
10394
runOnlyForDeploymentPostprocessing = 0;
@@ -107,7 +98,6 @@
10798
buildActionMask = 2147483647;
10899
files = (
109100
19BA88FF1F84392900741C5A /* RCTFileReaderModule.h in Headers */,
110-
1946172B225F085900E4E008 /* RCTBlobCollector.h in Headers */,
111101
AD0871181E215ED1007D136D /* RCTBlobManager.h in Headers */,
112102
);
113103
runOnlyForDeploymentPostprocessing = 0;
@@ -172,7 +162,6 @@
172162
developmentRegion = English;
173163
hasScannedForEncodings = 0;
174164
knownRegions = (
175-
English,
176165
en,
177166
);
178167
mainGroup = 358F4ECE1D1E81A9004DF814;
@@ -191,7 +180,6 @@
191180
isa = PBXSourcesBuildPhase;
192181
buildActionMask = 2147483647;
193182
files = (
194-
1946172C225F085900E4E008 /* RCTBlobCollector.mm in Sources */,
195183
ADDFBA6D1F33455F0064C998 /* RCTFileReaderModule.m in Sources */,
196184
AD9A43C31DFC7126008DC588 /* RCTBlobManager.mm in Sources */,
197185
);
@@ -201,7 +189,6 @@
201189
isa = PBXSourcesBuildPhase;
202190
buildActionMask = 2147483647;
203191
files = (
204-
1946172D225F085900E4E008 /* RCTBlobCollector.mm in Sources */,
205192
19BA89011F84393D00741C5A /* RCTFileReaderModule.m in Sources */,
206193
ADD01A711E09404A00F6D226 /* RCTBlobManager.mm in Sources */,
207194
);

Libraries/Blob/RCTBlobCollector.h

-30
This file was deleted.

Libraries/Blob/RCTBlobCollector.mm

-52
This file was deleted.

Libraries/Blob/RCTBlobManager.mm

-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import <React/RCTNetworking.h>
1414
#import <React/RCTUtils.h>
1515
#import <React/RCTWebSocketModule.h>
16-
#import "RCTBlobCollector.h"
1716

1817
static NSString *const kBlobURIScheme = @"blob";
1918

@@ -34,16 +33,13 @@ @implementation RCTBlobManager
3433
RCT_EXPORT_MODULE(BlobModule)
3534

3635
@synthesize bridge = _bridge;
37-
@synthesize methodQueue = _methodQueue;
3836

3937
- (void)setBridge:(RCTBridge *)bridge
4038
{
4139
_bridge = bridge;
4240

4341
std::lock_guard<std::mutex> lock(_blobsMutex);
4442
_blobs = [NSMutableDictionary new];
45-
46-
facebook::react::RCTBlobCollector::install(self);
4743
}
4844

4945
+ (BOOL)requiresMainQueueSetup

0 commit comments

Comments
 (0)