Commit Graph

24 Commits

Author SHA1 Message Date
Brent Vatne 0093dcc9c5 Don't show keyboard shortcuts with redbox on device
Summary:
Unless there is some really fancy way to make pressing the keyboard shortcuts like cmd+r from your dev machine and have it reload on your device like you can in the simulator, we probably shouldn't display these when running on device.

![img_4679](https://cloud.githubusercontent.com/assets/90494/17316248/331d890a-5827-11e6-9796-0f2bf24315d7.PNG)

<img width="487" alt="screen shot 2016-08-01 at 8 29 41 pm" src="https://cloud.githubusercontent.com/assets/90494/17316250/3b174e5c-5827-11e6-8337-ac0c01843fae.png">

![img_4677](https://cloud.githubusercontent.com/assets/90494/17316257/47aebcd6-5827-11e6-8a16-b128275f73e8.JPG)
Closes https://github.com/facebook/react-native/pull/9154

Differential Revision: D3663618

Pulled By: javache

fbshipit-source-id: 22d85d65702fa8d99788b79d04136c36da0d5b66
2016-08-03 17:43:49 -07:00
David Goldman 9d2e6a2f8a Add ability to customize error messages and stacks within the iOS redbox
Reviewed By: javache

Differential Revision: D3517605

fbshipit-source-id: a2efba80bbe1f6c74bf4e01f7807389962cb2463
2016-07-18 11:28:36 -07:00
Pieter De Baets 7b7ecdf337 Cleanup warnings
Reviewed By: majak

Differential Revision: D3542606

fbshipit-source-id: 41246a012a32fafc4ddbb307c7b9919e3c203393
2016-07-12 05:59:12 -07:00
Alex Kotliarskyi e5650560c0 Class for JS stack frames instead of dictionaries
Summary:
Currently React Native codebase treats JS stack traces as array of dictionaries.

This diff switches the Red Box to use new `RCTJSStackFrame` for internal data representation, while keeping the exposed API unchanged. The next step would be to replace the rest of manual parsing and usage of dictionaries.

The new class has ability to parse the stack from raw strings or dictionaries.

Depends on D3429031

Reviewed By: javache

Differential Revision: D3473199

fbshipit-source-id: 90d2a4f5e8e054b75c99905f35c2ee54927bb311
2016-07-11 06:13:32 -07:00
Skotch Vail bcf4bb6edd Automated changes to remove implicit capture of self in blocks: Libraries/FBReactKit/BUCK
Reviewed By: javache

Differential Revision: D3442470

fbshipit-source-id: 584a2bb3df5f7122166778b8fd44fae45560491e
2016-07-07 12:44:14 -07:00
Pieter De Baets 33d59137a5 Fix missing methods in !RCT_DEBUG
Reviewed By: bestander

Differential Revision: D3508704

fbshipit-source-id: 82c38819a83a50e0d5ba25480b5b4b7290c92e13
2016-07-01 03:13:18 -07:00
Marc Horowitz d1d9045eb4 Display JS exceptions and stacks in a red box.
Reviewed By: javache

Differential Revision: D3429031

fbshipit-source-id: a7ffd71151d8d78ccf8f0cc45807762b601cd112
2016-06-30 19:43:28 -07:00
Alex Kotliarskyi 0656b96354 Redbox: skip column number if it is 0
Summary:
Format before:
```
methodName
file_name.js @ 42:0
```

Format after
```
methodName
file_name.js:42
```

Reviewed By: javache

Differential Revision: D3350320

fbshipit-source-id: 456deb66bd34deb24bf8b8aa958883bdf4f99129
2016-05-27 11:43:34 -07:00
Chris Evans 5047f6f54c Add Copy Stack button to Red Box (iOS)
Summary:
Added a button to the iOS Red Box to enable copying of the error and stack trace to the clipboard to make it easier to paste the error and stack into bug reports or other text windows. Clicking the Copy button on the bottom of the RedBox screen or pressing Cmd-Option-C keyboard shortcut in the simulator will copy the full stack trace as text to the iOS pasteboard and when in the simulator you can then hit Command-C to get the text to the Mac's pasteboard for pasting in your favorite reporting/tracking app.

No tests for this change - I don't see any tests to extend for the RCTRedBoxWindow class. No impact on APIs or core React Native functionality. I validated it by running test React Native apps with red box errors and both hitting the copy button or using the command key shortcut in the emulator to get the text of the stack to the iOS pasteboard.
![redboxcopybutton](https://cloud.githubusercontent.com/assets/7173455/15258992/7b1e849c-1903-11e6-8813-6e853db5db54.png)
Closes https://github.com/facebook/react-native/pull/7557

Differential Revision: D3311743

Pulled By: javache

fbshipit-source-id: 76d1ac8ab93f40696c6a2369dae2245194db095a
2016-05-17 12:28:21 -07:00
Jean Regisser 037e9ba945 Fixed unable to open red box stack frame in editor when running on iOS device
Summary:
Hi,

I noticed touching stack frames from the red box when running from an iOS device wouldn't open my editor (was working fine from the simulator).
Here's a fix.

Let me know if everything looks correct.

Thanks,
Closes https://github.com/facebook/react-native/pull/7088

Differential Revision: D3235102

Pulled By: javache

fb-gh-sync-id: 06e6c3f9164e987ea9bf71d16fe360dc37036c8d
fbshipit-source-id: 06e6c3f9164e987ea9bf71d16fe360dc37036c8d
2016-04-28 11:39:18 -07:00
Pieter De Baets 5cdfe0f4b1 Report JSC errors as JS exceptions
Summary:When JSC throws an error on startup (e.g. a SyntaxError) or when invoking a method that is not caught by RCTExceptionsManager, we previously just reported is a native error, with a (useless) native stack trace in the redbox. This changes that behaviour to report a JS stacktrace.

The same issue was previously reported here: https://github.com/facebook/react-native/pull/5677

Reviewed By: majak

Differential Revision: D3037387

fb-gh-sync-id: 06f8333e0eb50dcef0b26284754262301b8a5f08
fbshipit-source-id: 06f8333e0eb50dcef0b26284754262301b8a5f08
2016-04-20 09:13:29 -07:00
Martín Bigio f2438b440d Hot Loading Sourcemaps
Summary:
public

To make sourcemaps work on Hot Loading work, we'll need to be able to serve them for each module that is dynamically replaced. To do so we introduced a new parameter to the bundler, namely `entryModuleOnly` to decide whether or not to process the full dependency tree or just the module associated to the entry file. Also we need to add `//sourceMappingURL` to the HMR updates so that in case of an error the runtime retrieves the sourcemaps for the file on which an error occurred from the server.

Finally, we need to refactor a bit how we load the HMR updates into JSC. Unfortunately, if the code is eval'ed when an error is thrown, the line and column number are missing. This is a bug/missing feature in JSC. To walkaround the issue we need to eval the code on native. This adds a bit of complexity to HMR as for both platforms we'll have to have a thin module to inject code but I don't see any other alternative. when debugging this is not needed as Chrome supports sourceMappingURLs on eval'ed code

Reviewed By: javache

Differential Revision: D2841788

fb-gh-sync-id: ad9370d26894527a151cea722463e694c670227e
2016-01-27 14:55:36 -08:00
Nick Lockwood 7419a82bd7 Handle bad JSON data without crashing
Summary:
public
NSJSONSerialization throws an exception when it encounters bad JSON data, including NaN values, which may not be a programming error.

This diff adds code to catch those exceptions and convert to an error. Also, if no error handling is in place, RCTJSONStringify will now display a redbox, and attempt to recover by sanitizing the JSON data and retrying.

Reviewed By: javache

Differential Revision: D2854778

fb-gh-sync-id: 18e6990af0d91083496d6a0b75c31a94ed9454a5
2016-01-26 06:13:29 -08:00
Nick Lockwood 060664fd3d Refactored module access to allow for lazy loading
Summary: public

The `bridge.modules` dictionary provides access to all native modules, but this API requires that every module is initialized in advance so that any module can be accessed.

This diff introduces a better API that will allow modules to be initialized lazily as they are needed, and deprecates `bridge.modules` (modules that use it will still work, but should be rewritten to use `bridge.moduleClasses` or `-[bridge moduleForName/Class:` instead.

The rules are now as follows:

* Any module that overrides `init` or `setBridge:` will be initialized on the main thread when the bridge is created
* Any module that implements `constantsToExport:` will be initialized later when the config is exported (the module itself will be initialized on a background queue, but  `constantsToExport:` will still be called on the main thread.
* All other modules will be initialized lazily when a method is first called on them.

These rules may seem slightly arcane, but they have the advantage of not violating any assumptions that may have been made by existing code - any module written under the original assumption that it would be initialized synchronously on the main thread when the bridge is created should still function exactly the same, but modules that avoid overriding `init` or `setBridge:` will now be loaded lazily.

I've rewritten most of the standard modules to take advantage of this new lazy loading, with the following results:

Out of the 65 modules included in UIExplorer:

* 16 are initialized on the main thread when the bridge is created
* A further 8 are initialized when the config is exported to JS
* The remaining 41 will be initialized lazily on-demand

Reviewed By: jspahrsummers

Differential Revision: D2677695

fb-gh-sync-id: 507ae7e9fd6b563e89292c7371767c978e928f33
2015-11-25 04:49:45 -08:00
Martin Kralik c324286fb7 truncate redbox error
Summary: If a redbox error is too long it's not shown at all:
{F24443416}
This diff truncates it to its first 10000 chars, which should be good enough:
{F24443417}

The reason is a limitation of UILabel which backs text property on the used UITableViewCell.
Ideally we would use a custom cell with UITextView, but I don't feel there is any value in displaying super long error messages in a redbox.

public

Reviewed By: jspahrsummers, nicklockwood

Differential Revision: D2690638

fb-gh-sync-id: d9b3fcecd2602e8c2618afe1bb97221c2e506605
2015-11-24 06:29:29 -08:00
Pieter De Baets 05996963c9 Cleanup RedBox display of native errors
Reviewed By: nicklockwood

Differential Revision: D2615507

fb-gh-sync-id: 94f8013b418a3b95508cc55b9302fde4325bfcbf
2015-11-04 12:12:33 -08:00
Nick Lockwood c5b990f65f Added lightweight generic annotations
Summary: public

Added lightweight genarics annotations to make the code more readable and help the compiler catch bugs.

Fixed some type bugs and improved bridge validation in a few places.

Reviewed By: javache

Differential Revision: D2600189

fb-gh-sync-id: f81e22f2cdc107bf8d0b15deec6d5b83aacc5b56
2015-11-03 14:49:30 -08:00
Pieter De Baets 3a664a0008 Log column number in RCTRedBox messages
Reviewed By: @jspahrsummers

Differential Revision: D2489364
2015-09-29 09:22:14 -07:00
Yusef Napora 2f9bd1f62f App Extension support
Summary: This adds workarounds for the code that was preventing React from compiling when linked against an iOS App Extension target.

Some iOS APIs are unavailable to App Extensions, and Xcode's static analysis will catch attempts to use methods that have been flagged as unavailable.

React currently uses two APIs that are off limits to extensions: `[UIApplication sharedApplication]` and `[UIAlertView initWith ...]`.

This commit adds a helper function to `RCTUtils.[hm]` called `RCTRunningInAppExtension()`, which returns `YES` if, at runtime, it can be determined that we're running in an app extension (by checking whether the path to `[NSBundle mainBundle]` has the `"appex"` path extension).

It also adds a `RCTSharedApplication()` function, which will return `nil` if running in an App Extension. If running in an App, `RCTSharedApplication()` calls `sharedApplication` by calling `performSelector:` on the `UIApplication` class.  This passes the static analysis check, and, in my opinion, obeys the "spirit of th
Closes https://github.com/facebook/react-native/pull/1895

Reviewed By: @​svcscm

Differential Revision: D2224128

Pulled By: @nicklockwood
2015-09-22 10:46:26 -07:00
Nick Lockwood b450e36ef8 Fixed chrome debug persistence + crash
Reviewed By: @tadeuzagallo

Differential Revision: D2443181
2015-09-15 11:20:23 -07:00
Pieter De Baets 371aeceb72 Small perf improvement to RCTPerfStats and RCTBridgeModuleNameForClass 2015-08-25 04:48:39 -08:00
Nick Lockwood 4382c0e8f4 Fixed redbox rotation
Summary:
Added autoresizing constraints to the redbox layout so that it resizes correctly when the screen is rotated.
2015-08-25 02:20:26 -08:00
Nick Lockwood 88e0bbc469 Ran Convert > To Modern Objective C Syntax 2015-08-25 01:08:49 -08:00
Nick Lockwood 2cd02d94ff Converted RCTRedBox to a bridge module 2015-08-21 02:53:55 -07:00