@maccesar/titools 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -61
- package/lib/cleanup.js +29 -0
- package/lib/commands/agents.js +8 -7
- package/lib/commands/skills.js +118 -23
- package/lib/config.js +13 -15
- package/lib/installer.js +5 -3
- package/lib/utils.js +36 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +188 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +233 -0
- package/skills/alloy-guides/references/CONCEPTS.md +171 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +279 -0
- package/skills/alloy-guides/references/MODELS.md +742 -0
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +482 -0
- package/skills/alloy-guides/references/PURGETSS.md +57 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +235 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +375 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +102 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +581 -0
- package/skills/alloy-guides/references/WIDGETS.md +160 -0
- package/skills/alloy-howtos/SKILL.md +179 -0
- package/skills/alloy-howtos/references/best_practices.md +121 -0
- package/skills/alloy-howtos/references/cli_reference.md +230 -0
- package/skills/alloy-howtos/references/config_files.md +158 -0
- package/skills/alloy-howtos/references/custom_tags.md +148 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +78 -0
- package/skills/alloy-howtos/references/samples.md +156 -0
- package/skills/purgetss/SKILL.md +6 -3
- package/skills/purgetss/references/EXAMPLES.md +8 -6
- package/skills/purgetss/references/app-branding.md +5 -0
- package/skills/purgetss/references/apply-directive.md +1 -1
- package/skills/purgetss/references/class-categories.md +1 -1
- package/skills/purgetss/references/class-index-properties.md +618 -0
- package/skills/purgetss/references/class-index.md +4 -610
- package/skills/purgetss/references/cli-commands.md +15 -0
- package/skills/purgetss/references/custom-fonts.md +39 -36
- package/skills/purgetss/references/custom-rules.md +1 -1
- package/skills/purgetss/references/customization-deep-dive.md +64 -1
- package/skills/purgetss/references/icon-fonts.md +2 -0
- package/skills/purgetss/references/migration-guide.md +53 -1
- package/skills/purgetss/references/multi-density-images.md +53 -2
- package/skills/purgetss/references/svg-pipeline.md +249 -0
- package/skills/purgetss/references/tikit-components.md +2 -2
- package/skills/purgetss/references/titanium-resets.md +2 -2
- package/skills/purgetss/references/ui-ux-design.md +7 -5
- package/skills/purgetss/references/version-history.md +12 -0
- package/skills/ti-api/SKILL.md +128 -0
- package/skills/ti-api/references/api-android.md +675 -0
- package/skills/ti-api/references/api-app-platform.md +636 -0
- package/skills/ti-api/references/api-core.md +764 -0
- package/skills/ti-api/references/api-data-network.md +641 -0
- package/skills/ti-api/references/api-media.md +655 -0
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
- package/skills/ti-api/references/api-modules-map.md +632 -0
- package/skills/ti-api/references/api-modules-nfc.md +725 -0
- package/skills/ti-api/references/api-modules-social-misc.md +526 -0
- package/skills/ti-api/references/api-services.md +700 -0
- package/skills/ti-api/references/api-ui-android.md +499 -0
- package/skills/ti-api/references/api-ui-extras.md +702 -0
- package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
- package/skills/ti-api/references/api-ui-ios.md +756 -0
- package/skills/ti-api/references/api-ui-lists.md +581 -0
- package/skills/ti-api/references/api-ui-text-input.md +607 -0
- package/skills/ti-api/references/api-ui-views.md +572 -0
- package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
- package/skills/ti-api/references/api-xml-global.md +743 -0
- package/skills/ti-guides/SKILL.md +82 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +155 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +373 -0
- package/skills/ti-guides/references/application-frameworks.md +366 -0
- package/skills/ti-guides/references/cli-reference.md +700 -0
- package/skills/ti-guides/references/coding-best-practices.md +150 -0
- package/skills/ti-guides/references/commonjs-advanced.md +279 -0
- package/skills/ti-guides/references/hello-world.md +99 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +458 -0
- package/skills/ti-guides/references/javascript-primer.md +402 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +172 -0
- package/skills/ti-guides/references/style-and-conventions.md +104 -0
- package/skills/ti-guides/references/tiapp-config.md +655 -0
- package/skills/ti-howtos/SKILL.md +131 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +609 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +96 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +162 -0
- package/skills/ti-howtos/references/cross-platform-development.md +358 -0
- package/skills/ti-howtos/references/debugging-profiling.md +473 -0
- package/skills/ti-howtos/references/extending-titanium.md +684 -0
- package/skills/ti-howtos/references/google-maps-v2.md +172 -0
- package/skills/ti-howtos/references/ios-map-kit.md +149 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +595 -0
- package/skills/ti-howtos/references/local-data-sources.md +310 -0
- package/skills/ti-howtos/references/location-and-maps.md +267 -0
- package/skills/ti-howtos/references/media-apis.md +268 -0
- package/skills/ti-howtos/references/notification-services.md +539 -0
- package/skills/ti-howtos/references/remote-data-sources.md +339 -0
- package/skills/ti-howtos/references/tutorials.md +552 -0
- package/skills/ti-howtos/references/using-modules.md +182 -0
- package/skills/ti-howtos/references/web-content-integration.md +288 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +125 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
# Debugging and profiling
|
|
2
|
+
|
|
3
|
+
Guide to debugging Titanium apps, managing memory, finding leaks, and using native tools.
|
|
4
|
+
|
|
5
|
+
## Debugging overview
|
|
6
|
+
|
|
7
|
+
### Essential elements of debugging
|
|
8
|
+
|
|
9
|
+
1. Gather information: clear, accurate description of the problem
|
|
10
|
+
2. Reproduce: consistent steps to recreate the issue
|
|
11
|
+
3. Deduce: logical reasoning to isolate the cause
|
|
12
|
+
4. Experiment: try fixes iteratively, track what works
|
|
13
|
+
5. Be tenacious: methodical persistence wins
|
|
14
|
+
6. Track work: document bugs and solutions
|
|
15
|
+
|
|
16
|
+
### Debugging techniques
|
|
17
|
+
|
|
18
|
+
1. Print tracing (logging)
|
|
19
|
+
```javascript
|
|
20
|
+
Ti.API.info(`Variable value: ${myVar}`);
|
|
21
|
+
Ti.API.warn('Warning message');
|
|
22
|
+
Ti.API.error('Error occurred');
|
|
23
|
+
Ti.API.log('info', 'Custom level message');
|
|
24
|
+
Ti.API.debug('Debug info'); // Only in dev mode
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. Crash log evaluation
|
|
28
|
+
- Build logs (compilation errors)
|
|
29
|
+
- Runtime logs (app crashes)
|
|
30
|
+
- Simulator/Emulator logs
|
|
31
|
+
- Device logs
|
|
32
|
+
|
|
33
|
+
3. Interactive debugging
|
|
34
|
+
- Breakpoints in Studio/IDE
|
|
35
|
+
- Variable inspection
|
|
36
|
+
- Step-through execution
|
|
37
|
+
|
|
38
|
+
## Memory management
|
|
39
|
+
|
|
40
|
+
### How JavaScript manages memory
|
|
41
|
+
|
|
42
|
+
Garbage collection: JavaScript uses automatic mark-and-sweep.
|
|
43
|
+
|
|
44
|
+
1. Interpreter scans memory periodically
|
|
45
|
+
2. Marks objects with active references
|
|
46
|
+
3. Destroys unmarked objects
|
|
47
|
+
4. Frees their memory
|
|
48
|
+
|
|
49
|
+
Implication: objects with no references are cleaned up automatically.
|
|
50
|
+
|
|
51
|
+
### How Titanium manages memory
|
|
52
|
+
|
|
53
|
+
Titanium bridges JavaScript and native OS objects:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// JavaScript object + Native proxy
|
|
57
|
+
const button = Ti.UI.createButton({ title: 'Click me' });
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Key rule: setting a JavaScript object to `null` destroys both the JavaScript object and the native proxy.
|
|
61
|
+
|
|
62
|
+
### Releasing memory properly
|
|
63
|
+
|
|
64
|
+
Complete cleanup:
|
|
65
|
+
```javascript
|
|
66
|
+
let view = Ti.UI.createView({ backgroundColor: 'white' });
|
|
67
|
+
win.add(view);
|
|
68
|
+
|
|
69
|
+
// Later: remove and nullify
|
|
70
|
+
win.remove(view);
|
|
71
|
+
view = null; // Destroys native proxy
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Incomplete cleanup (memory leak):
|
|
75
|
+
```javascript
|
|
76
|
+
let view = Ti.UI.createView({ backgroundColor: 'white' });
|
|
77
|
+
win.add(view);
|
|
78
|
+
|
|
79
|
+
// Later: only remove
|
|
80
|
+
win.remove(view); // view object still exists in memory
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Parent-child relationships
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Good: children not referenced elsewhere
|
|
87
|
+
let view = Ti.UI.createView({
|
|
88
|
+
backgroundColor: 'white'
|
|
89
|
+
});
|
|
90
|
+
view.add(Ti.UI.createButton({ title: 'Click' })); // Anonymous child
|
|
91
|
+
|
|
92
|
+
win.remove(view);
|
|
93
|
+
view = null; // Destroys view and button
|
|
94
|
+
|
|
95
|
+
// Bad: children referenced separately
|
|
96
|
+
const button = Ti.UI.createButton({ title: 'Click' });
|
|
97
|
+
let view = Ti.UI.createView({ backgroundColor: 'white' });
|
|
98
|
+
view.add(button);
|
|
99
|
+
|
|
100
|
+
win.remove(view);
|
|
101
|
+
view = null; // Destroys view, but button still exists
|
|
102
|
+
button = null; // Now button is destroyed
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Platform memory limits
|
|
106
|
+
|
|
107
|
+
| Platform | Memory limit |
|
|
108
|
+
| -------- | -------------------------------------- |
|
|
109
|
+
| iPhone | ~10% of system memory |
|
|
110
|
+
| iPad | 30-50 MB (smaller is better) |
|
|
111
|
+
| Android | 24-32 MB heap (128 MB with large heap) |
|
|
112
|
+
|
|
113
|
+
Notes for iOS:
|
|
114
|
+
- Apple does not publish exact limits
|
|
115
|
+
- The jetsam process can terminate your app
|
|
116
|
+
- "Jetsam" in crash logs often means a memory issue
|
|
117
|
+
|
|
118
|
+
Important: memory is not storage. A 16GB device does not mean 16GB for your app. Limits may be higher on newer devices, but optimize for the lowest common denominator.
|
|
119
|
+
|
|
120
|
+
## Memory leak detection
|
|
121
|
+
|
|
122
|
+
### Common leak sources
|
|
123
|
+
|
|
124
|
+
1. Global event listeners
|
|
125
|
+
```javascript
|
|
126
|
+
// Leak: listener keeps reference to window
|
|
127
|
+
Ti.App.addEventListener('custom:event', (e) => {
|
|
128
|
+
// Uses window variables
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Fix: remove listeners when closing window
|
|
133
|
+
```javascript
|
|
134
|
+
const myHandler = (e) => {
|
|
135
|
+
// Handle event
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
Ti.App.addEventListener('custom:event', myHandler);
|
|
139
|
+
|
|
140
|
+
win.addEventListener('close', () => {
|
|
141
|
+
Ti.App.removeEventListener('custom:event', myHandler);
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
2. Objects in closures
|
|
146
|
+
```javascript
|
|
147
|
+
// Leak: closure retains object reference
|
|
148
|
+
function createWindow() {
|
|
149
|
+
const data = []; // Large array
|
|
150
|
+
return Ti.UI.createWindow({
|
|
151
|
+
listener: () => {
|
|
152
|
+
data.push('more'); // Closure reference
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Fix: pass data as an argument instead of keeping it in a closure.
|
|
159
|
+
|
|
160
|
+
3. Hidden views
|
|
161
|
+
```javascript
|
|
162
|
+
// Leak: hidden view still consumes memory
|
|
163
|
+
view.visible = false; // Not enough
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Fix: remove and nullify when not needed
|
|
167
|
+
```javascript
|
|
168
|
+
view.visible = false;
|
|
169
|
+
parent.remove(view);
|
|
170
|
+
view = null;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Debugging memory on iOS (Instruments)
|
|
174
|
+
|
|
175
|
+
Setup:
|
|
176
|
+
1. Open app in iOS Simulator
|
|
177
|
+
2. Xcode → Open Developer Tool → Instruments
|
|
178
|
+
3. Choose Allocations template
|
|
179
|
+
4. Choose Target → Your App
|
|
180
|
+
5. Click Record
|
|
181
|
+
|
|
182
|
+
Key columns:
|
|
183
|
+
| Column | What it shows |
|
|
184
|
+
| ----------------------------- | ------------------------ |
|
|
185
|
+
| Persistent Bytes (Live Bytes) | Memory currently in use |
|
|
186
|
+
| #Persistent (#Living) | Active object count |
|
|
187
|
+
| #Transient (#Transitory) | Ready to garbage collect |
|
|
188
|
+
|
|
189
|
+
Identifying leaks:
|
|
190
|
+
1. Filter for `Ti` prefix (Titanium objects)
|
|
191
|
+
2. Watch #Living as you use the app
|
|
192
|
+
3. If it grows continuously, you have a leak
|
|
193
|
+
4. #Transitory growing is fine (will be GC'd)
|
|
194
|
+
|
|
195
|
+
Example workflow:
|
|
196
|
+
```
|
|
197
|
+
1. Filter: "TiUITableView" (table views)
|
|
198
|
+
2. Open/close a table view screen
|
|
199
|
+
3. Click "Cause GC" (garbage collection)
|
|
200
|
+
4. Check if #Living returns to previous value
|
|
201
|
+
5. If not, the leak is in that screen
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Debugging memory on Android (DDMS)
|
|
205
|
+
|
|
206
|
+
Setup:
|
|
207
|
+
1. Add to `tiapp.xml`:
|
|
208
|
+
```xml
|
|
209
|
+
<android xmlns:android="http://schemas.android.com/apk/res/android">
|
|
210
|
+
<manifest>
|
|
211
|
+
<application android:debuggable="true">
|
|
212
|
+
</application>
|
|
213
|
+
</manifest>
|
|
214
|
+
</android>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
2. Build app for emulator
|
|
218
|
+
3. Open DDMS (Android Device Monitor)
|
|
219
|
+
|
|
220
|
+
Monitoring:
|
|
221
|
+
1. Select your app process
|
|
222
|
+
2. Click Update Heap
|
|
223
|
+
3. Click Cause GC to force garbage collection
|
|
224
|
+
4. Watch Allocated and # Objects values
|
|
225
|
+
|
|
226
|
+
Identifying leaks:
|
|
227
|
+
1. Note initial values after GC
|
|
228
|
+
2. Exercise app (open/close screens)
|
|
229
|
+
3. Click Cause GC again
|
|
230
|
+
4. If values do not return to baseline, there is a leak
|
|
231
|
+
|
|
232
|
+
## Android debugging tools
|
|
233
|
+
|
|
234
|
+
### DDMS (Dalvik Debug Monitor Service)
|
|
235
|
+
|
|
236
|
+
Features:
|
|
237
|
+
- View log output
|
|
238
|
+
- Explore file system
|
|
239
|
+
- Simulate network conditions
|
|
240
|
+
- Simulate calls/SMS
|
|
241
|
+
- Set GPS coordinates
|
|
242
|
+
- Monitor memory
|
|
243
|
+
|
|
244
|
+
#### Log output with DDMS
|
|
245
|
+
|
|
246
|
+
1. Open DDMS
|
|
247
|
+
2. Select device/emulator
|
|
248
|
+
3. View log in lower pane
|
|
249
|
+
4. Add filter: Log Tag = `TiAPI`
|
|
250
|
+
|
|
251
|
+
#### Simulate network conditions
|
|
252
|
+
|
|
253
|
+
Emulator Control panel:
|
|
254
|
+
- Voice/Data state (home, roaming)
|
|
255
|
+
- Data speed and latency
|
|
256
|
+
- Test app behavior in poor conditions
|
|
257
|
+
|
|
258
|
+
#### Simulate calls/SMS
|
|
259
|
+
|
|
260
|
+
Emulator Control → Telephony Actions:
|
|
261
|
+
- Incoming voice call
|
|
262
|
+
- Incoming SMS message
|
|
263
|
+
- Test app interruption handling
|
|
264
|
+
|
|
265
|
+
#### Set GPS coordinates
|
|
266
|
+
|
|
267
|
+
Emulator Control → Location Controls:
|
|
268
|
+
- Enter latitude/longitude
|
|
269
|
+
- Click Send
|
|
270
|
+
- Emulator uses these as current location
|
|
271
|
+
|
|
272
|
+
#### File system exploration
|
|
273
|
+
|
|
274
|
+
Device → File Explorer:
|
|
275
|
+
- Browse entire file system
|
|
276
|
+
- Pull files (copy to computer)
|
|
277
|
+
- Push files (copy to device)
|
|
278
|
+
- Delete files
|
|
279
|
+
|
|
280
|
+
#### Memory monitoring
|
|
281
|
+
|
|
282
|
+
Less useful for Titanium (JavaScript runs in one process), but it can show overall memory trends.
|
|
283
|
+
|
|
284
|
+
### ADB (Android Debug Bridge)
|
|
285
|
+
|
|
286
|
+
#### Log output
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# View all logs
|
|
290
|
+
adb logcat
|
|
291
|
+
|
|
292
|
+
# Device only
|
|
293
|
+
adb -d logcat
|
|
294
|
+
|
|
295
|
+
# Emulator only
|
|
296
|
+
adb -e logcat
|
|
297
|
+
|
|
298
|
+
# Specific device
|
|
299
|
+
adb -s emulator-5556 logcat
|
|
300
|
+
|
|
301
|
+
# Filter for Titanium
|
|
302
|
+
adb logcat -s TiAPI
|
|
303
|
+
# or
|
|
304
|
+
adb logcat | grep TiAPI
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### File system
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Open shell
|
|
311
|
+
adb shell
|
|
312
|
+
|
|
313
|
+
# List files
|
|
314
|
+
ls -la
|
|
315
|
+
cd /some/path
|
|
316
|
+
|
|
317
|
+
# Exit shell
|
|
318
|
+
exit
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Transfer files
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# Copy file TO device
|
|
325
|
+
adb push local.txt /sdcard/local.txt
|
|
326
|
+
|
|
327
|
+
# Copy file FROM device
|
|
328
|
+
adb pull /sdcard/remote.txt local.txt
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
#### Access SQLite databases
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
adb shell
|
|
335
|
+
|
|
336
|
+
# List databases
|
|
337
|
+
ls /data/data/com.example.app/databases/
|
|
338
|
+
|
|
339
|
+
# Open database
|
|
340
|
+
sqlite3 /data/data/com.example.app/databases/mydb.sqlite
|
|
341
|
+
|
|
342
|
+
# Query
|
|
343
|
+
SELECT * FROM tablename;
|
|
344
|
+
|
|
345
|
+
# Exit
|
|
346
|
+
.exit
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Creating emulators
|
|
350
|
+
|
|
351
|
+
> **⚠️ AVD Manager moved to Android Studio**
|
|
352
|
+
> The legacy `android` CLI (`android create avd`, `android avd`) was removed in Android SDK Tools 25.3. Use Android Studio's built-in **AVD Manager** (Tools → Device Manager) or the command-line `avdmanager` tool instead.
|
|
353
|
+
|
|
354
|
+
Command line (modern):
|
|
355
|
+
```bash
|
|
356
|
+
# List available system images
|
|
357
|
+
sdkmanager --list | grep system-images
|
|
358
|
+
|
|
359
|
+
# Create AVD with avdmanager
|
|
360
|
+
avdmanager create avd -n my_emulator -k "system-images;android-34;google_apis;x86_64"
|
|
361
|
+
|
|
362
|
+
# Launch emulator
|
|
363
|
+
emulator -avd my_emulator
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Android Studio (GUI): Tools → Device Manager → Create Device.
|
|
367
|
+
|
|
368
|
+
### Modifying emulators
|
|
369
|
+
|
|
370
|
+
Increase disk space:
|
|
371
|
+
Edit `~/.android/avd/<NAME>.avd/config.ini`:
|
|
372
|
+
```
|
|
373
|
+
disk.dataPartition.size=1024m
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Scale on-the-fly:
|
|
377
|
+
```bash
|
|
378
|
+
# Get emulator port
|
|
379
|
+
adb devices
|
|
380
|
+
# emulator-5560
|
|
381
|
+
|
|
382
|
+
# Connect with telnet
|
|
383
|
+
telnet localhost 5560
|
|
384
|
+
|
|
385
|
+
# Scale to 75%
|
|
386
|
+
window scale 0.75
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## iOS debugging tools
|
|
390
|
+
|
|
391
|
+
### Instruments
|
|
392
|
+
|
|
393
|
+
Key templates for Titanium debugging:
|
|
394
|
+
- Allocations: track object creation and live object counts. Look at Persistent Bytes (Live Bytes) and #Persistent (#Living).
|
|
395
|
+
- Leaks: detect memory leaks in real time. Shows objects that are allocated but never released.
|
|
396
|
+
- Time Profiler: identify CPU-intensive operations and bottlenecks.
|
|
397
|
+
- System Trace: system-level events and thread activity.
|
|
398
|
+
- Zombies: detect messages sent to deallocated objects (debug builds only). Useful for over-released objects.
|
|
399
|
+
|
|
400
|
+
### Xcode build debugging
|
|
401
|
+
|
|
402
|
+
For native debugging, open the Xcode project in `build/iphone`:
|
|
403
|
+
1. Product → Profile
|
|
404
|
+
2. Choose Instruments template
|
|
405
|
+
3. More accurate than attaching to a running process
|
|
406
|
+
|
|
407
|
+
### Console logs
|
|
408
|
+
|
|
409
|
+
Viewing in Studio:
|
|
410
|
+
- Console panel shows build/run output
|
|
411
|
+
|
|
412
|
+
Viewing separately:
|
|
413
|
+
```bash
|
|
414
|
+
# For running apps
|
|
415
|
+
tail -f ~/Library/Logs/CoreSimulator/<SIMULATOR_ID>/system.log
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## 6. Automation and UI testing
|
|
419
|
+
|
|
420
|
+
For CI/CD pipelines, automated deployment, and functional testing, see:
|
|
421
|
+
|
|
422
|
+
- Automation with Fastlane and Appium: `automation-fastlane-appium.md`
|
|
423
|
+
|
|
424
|
+
## Best practices
|
|
425
|
+
|
|
426
|
+
### Memory management
|
|
427
|
+
|
|
428
|
+
1. Always nullify objects after removing them from the view hierarchy.
|
|
429
|
+
2. Remove event listeners when closing windows.
|
|
430
|
+
3. Avoid global variables; use namespaces or CommonJS.
|
|
431
|
+
4. Use a single execution context, not multiple URL-based windows.
|
|
432
|
+
5. Be careful with closures; they retain references.
|
|
433
|
+
6. Hide vs remove: hide for temporary, remove/nullify for permanent.
|
|
434
|
+
|
|
435
|
+
### Debugging
|
|
436
|
+
|
|
437
|
+
1. Log strategically and remove sensitive logs before production.
|
|
438
|
+
2. Use descriptive log messages and include variable values.
|
|
439
|
+
3. Test on real devices; simulators miss issues.
|
|
440
|
+
4. Profile early and often; do not wait for crashes.
|
|
441
|
+
5. Reproduce consistently; you cannot fix what you cannot reproduce.
|
|
442
|
+
6. Keep track of bugs; use an issue tracker.
|
|
443
|
+
|
|
444
|
+
### Performance
|
|
445
|
+
|
|
446
|
+
1. Avoid excessive polling; use events when possible.
|
|
447
|
+
2. Defer loading; load data as needed.
|
|
448
|
+
3. Optimize images; compress and use appropriate sizes.
|
|
449
|
+
4. Minimize bridge crossings; cache platform checks.
|
|
450
|
+
5. Test on slow networks; simulate poor conditions.
|
|
451
|
+
6. Profile before optimizing; measure first, then fix hotspots.
|
|
452
|
+
|
|
453
|
+
## Platform-specific notes
|
|
454
|
+
|
|
455
|
+
### Android
|
|
456
|
+
|
|
457
|
+
- Debuggable flag: required for native debugging
|
|
458
|
+
- Large heap: enable in `tiapp.xml` if needed
|
|
459
|
+
- ProGuard: can obfuscate and optimize code
|
|
460
|
+
- Multidex: may be needed for very large apps
|
|
461
|
+
|
|
462
|
+
### iOS
|
|
463
|
+
|
|
464
|
+
- Instruments: most powerful tool for iOS profiling
|
|
465
|
+
- Zombies: Instruments tool to find over-released objects
|
|
466
|
+
- Allocation tracker: shows object creation and lifecycle
|
|
467
|
+
- Time Profiler: identifies CPU bottlenecks
|
|
468
|
+
|
|
469
|
+
## Resources
|
|
470
|
+
|
|
471
|
+
- Video: Your Apps are Leaking (Codestrong 2011)
|
|
472
|
+
- Android DDMS docs: https://minimum-viable-product.github.io/marshmallow-docs/tools/debugging/ddms.html
|
|
473
|
+
- iOS Instruments guide: Apple Developer Documentation
|