Skip to content

Commit 7242ea9

Browse files
committed
test: trace NSMutableArray iOS hang
1 parent 1723f06 commit 7242ea9

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

test/runtime/fixtures/TNSTestNativeCallbacks.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,20 +331,44 @@ + (void)recordsPointer:(TNSSimpleStruct*)object {
331331
}
332332

333333
+ (void)apiNSMutableArrayMethods:(NSMutableArray*)object {
334+
NSLog(@"[NSMutableArrayMethods] native enter object=%p class=%@", object, NSStringFromClass([object class]));
335+
NSLog(@"[NSMutableArrayMethods] native before add b");
334336
[object addObject:@"b"];
337+
NSLog(@"[NSMutableArrayMethods] native after add b");
338+
NSLog(@"[NSMutableArrayMethods] native before add x");
335339
[object addObject:@"x"];
340+
NSLog(@"[NSMutableArrayMethods] native after add x");
341+
NSLog(@"[NSMutableArrayMethods] native before add c");
336342
[object addObject:@"c"];
343+
NSLog(@"[NSMutableArrayMethods] native after add c");
344+
NSLog(@"[NSMutableArrayMethods] native before add y");
337345
[object addObject:@"y"];
346+
NSLog(@"[NSMutableArrayMethods] native after add y");
347+
NSLog(@"[NSMutableArrayMethods] native before add z");
338348
[object addObject:@"z"];
349+
NSLog(@"[NSMutableArrayMethods] native after add z");
350+
NSLog(@"[NSMutableArrayMethods] native before insert a");
339351
[object insertObject:@"a" atIndex:0];
352+
NSLog(@"[NSMutableArrayMethods] native after insert a");
353+
NSLog(@"[NSMutableArrayMethods] native before remove index 2");
340354
[object removeObjectAtIndex:2];
355+
NSLog(@"[NSMutableArrayMethods] native after remove index 2");
356+
NSLog(@"[NSMutableArrayMethods] native before remove last");
341357
[object removeLastObject];
358+
NSLog(@"[NSMutableArrayMethods] native after remove last");
359+
NSLog(@"[NSMutableArrayMethods] native before subscript replace");
342360
object[3] = @"d";
361+
NSLog(@"[NSMutableArrayMethods] native after subscript replace");
362+
NSLog(@"[NSMutableArrayMethods] native before count/hash");
343363
TNSLog([NSString stringWithFormat:@"%tu%tu", [object count], [object hash]]);
364+
NSLog(@"[NSMutableArrayMethods] native after count/hash");
344365

366+
NSLog(@"[NSMutableArrayMethods] native before enumeration");
345367
for (id x in object) {
368+
NSLog(@"[NSMutableArrayMethods] native enumerate %@", x);
346369
TNSLog([NSString stringWithFormat:@"%@", x]);
347370
}
371+
NSLog(@"[NSMutableArrayMethods] native exit");
348372
}
349373

350374
+ (void)apiSwizzle:(TNSSwizzleKlass*)object {

test/runtime/runner/app/tests/ApiTests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,11 @@ describe(module.id, function () {
249249
it("NSMutableArrayMethods", function () {
250250
var JSMutableArray = NSMutableArray.extend({
251251
init: function () {
252+
console.log("[NSMutableArrayMethods] js init enter", this.nativeAddress);
252253
var self = NSMutableArray.prototype.init.apply(this, arguments);
254+
console.log("[NSMutableArrayMethods] js init base returned", self === this, self.nativeAddress);
253255
self._array = [];
256+
console.log("[NSMutableArrayMethods] js init array ready", self._array.length);
254257
return self;
255258
},
256259
// TODO
@@ -260,27 +263,40 @@ describe(module.id, function () {
260263
// NSMutableArray.prototype.dealloc.apply(this, arguments);
261264
// },
262265
insertObjectAtIndex: function (anObject, index) {
266+
console.log("[NSMutableArrayMethods] js insert enter", anObject, index, this._array && this._array.length);
263267
this._array.splice(index, 0, anObject);
268+
console.log("[NSMutableArrayMethods] js insert exit", this._array.length);
264269
},
265270
removeObjectAtIndex: function (index) {
271+
console.log("[NSMutableArrayMethods] js remove enter", index, this._array && this._array.length);
266272
this._array.splice(index, 1);
273+
console.log("[NSMutableArrayMethods] js remove exit", this._array.length);
267274
},
268275
addObject: function (anObject) {
276+
console.log("[NSMutableArrayMethods] js add enter", anObject, this._array && this._array.length);
269277
this._array.push(anObject);
278+
console.log("[NSMutableArrayMethods] js add exit", this._array.length);
270279
},
271280
removeLastObject: function () {
281+
console.log("[NSMutableArrayMethods] js removeLast enter", this._array && this._array.length);
272282
this._array.pop();
283+
console.log("[NSMutableArrayMethods] js removeLast exit", this._array.length);
273284
},
274285
replaceObjectAtIndexWithObject: function (index, anObject) {
286+
console.log("[NSMutableArrayMethods] js replace enter", index, anObject, this._array && this._array.length);
275287
this._array[index] = anObject;
288+
console.log("[NSMutableArrayMethods] js replace exit", this._array.length);
276289
},
277290
objectAtIndex: function (index) {
291+
console.log("[NSMutableArrayMethods] js objectAtIndex", index, this._array && this._array.length);
278292
return this._array[index];
279293
},
280294
get count() {
295+
console.log("[NSMutableArrayMethods] js count", this._array && this._array.length);
281296
return this._array.length;
282297
},
283298
get hash() {
299+
console.log("[NSMutableArrayMethods] js hash enter");
284300
return this.count;
285301
}
286302
}, {
@@ -289,7 +305,9 @@ describe(module.id, function () {
289305

290306
(function () {
291307
var array = new JSMutableArray();
308+
console.log("[NSMutableArrayMethods] js before native callback", array.nativeAddress, array._array && array._array.length);
292309
TNSTestNativeCallbacks.apiNSMutableArrayMethods(array);
310+
console.log("[NSMutableArrayMethods] js after native callback", array._array && array._array.length);
293311
}());
294312
gc();
295313

0 commit comments

Comments
 (0)