Fork me on GitHub
#cljsrn
<
2016-10-16
>
pesterhazy11:10:32

@levitanong what I do: 1. set max_old_space_size, 2. no advanced compilation on the cljs side and 3. use --dev in the bundle task

levitanong11:10:40

@pesterhazy 1. I’ve been meaning to ask someone: Is it max_old_space_size, or max-old-space-size? 😛 2. By that do you mean :optimizations :none in project.clj? 3. Where do i set this? I do see the resultant bundle have —dev true though...

pesterhazy11:10:15

wait let me check

levitanong11:10:32

Because I’ve looked around, and a lot of resources sometimes use _, and sometimes -.

levitanong11:10:08

based on the link you provided, it seems you mean use :optimizations :simple instead of :optimizations :advanced. My project.clj is already on :simple. 😞

levitanong11:10:44

I am also unsure what to do with the python script 😛 Sorry, pretty new to this, and I’ve never used python before

pesterhazy11:10:50

that's what I use

levitanong11:10:35

And i’m assuming that’ll still apply to re-natal?

levitanong11:10:25

Alas, it’s already set to 8192

pesterhazy11:10:41

node_modules/.bin/react-native bundle --help
Options:
  --entry-file        Path to the root JS file, either absolute or relative to JS root                                   [required]
  --platform          Either "ios" or "android"
  --transformer       Specify a custom transformer to be used                                                            [default: null]
  --dev               If false, warnings are disabled and the bundle is minified                                         [default: true]

pesterhazy11:10:11

if you set --dev true, the bundler will skip whole program optimization

pesterhazy11:10:17

that reduces the mem requirement

levitanong11:10:54

Ah, so in the project.pbxproj (apparently this is how re-natal does it) "export NODE_BINARY='node --max_old_space_size=8192'\n../node_modules/react-native/packager/react-native-xcode.sh” would be "export NODE_BINARY='node --max_old_space_size=8192 —dev true'\n../node_modules/react-native/packager/react-native-xcode.sh”

pesterhazy11:10:55

it also adds __DEV__=true; to the top of the file ,which you don't want for prod builds

pesterhazy11:10:09

hence the python script

levitanong11:10:43

oh it’s a regex string replace

pesterhazy11:10:12

have a look at the react-native-xcode.sh shell script

pesterhazy11:10:21

it takes a DEV variable

pesterhazy11:10:26

you'll need to adapt that

pesterhazy11:10:47

I don't use that script and instead build the bundle.js myself

levitanong11:10:16

Isn’t dev true by default though?

pesterhazy11:10:16

yes but I guess not for release builds?

pesterhazy11:10:09

DEV__=true gives you yellow boxes and worse perf

levitanong11:10:26

oddly enough, it seems re-natal spits out —dev true even for prod builds

levitanong11:10:56

I noticed your comment on one of the issues in react-native… something about child processes not inheriting the memory allocation. Could that be it?

pesterhazy11:10:06

yes I think so

pesterhazy11:10:31

I couldn't get to the bottom of how this works on node though

pesterhazy11:10:52

it's not really an ecosystem built for mem-intensive tasks

pesterhazy11:10:12

GC options are hardly even documented

levitanong11:10:14

Oh dear, that sounds like the root of the problem won’t be fixed anytime soon

pesterhazy11:10:48

my experience is that packager problems that don't affect the FB team don't get any attention

pesterhazy11:10:20

none of my issues have prompted a response so far

pesterhazy11:10:47

the packager is a true weakness of RN, which is sound engineering otherwise

pesterhazy12:10:20

@levitanong I'm sure you can make it work though. Try running the packager manually

pesterhazy12:10:48

the trouble with neatly packaged solutions like re-natal is that it's hard to peak under the covers

pesterhazy12:10:22

try to find the cljs bundle output and run react-native bundle --dev true manually

levitanong12:10:33

ok, will do that 😄

levitanong12:10:10

Yeah, I’d actually prefer to work with boot-react-native, but I figured re-natal was more mature

pesterhazy12:10:47

it might also be an idea reaching out to the node community to find out how to set node cli parameters of subprocesses

levitanong12:10:17

Would you say that react-native run-ios is a combination of react-native bundle and some other command?

pesterhazy12:10:30

no, it has nothing to do with bundle

pesterhazy12:10:58

it just compiles the objectivec code and launches it in the simulator

pesterhazy12:10:42

it also opens a new terminal window with the command react-native start if it isn't running yet

pesterhazy12:10:09

that's the packager running as a webserver (which is like a live version of react-native bundle)

pesterhazy12:10:17

but you can run that manually in a terminal yourself

levitanong12:10:06

I’m doing that right now, and I’m seeing a terminal output similar to when "node_modules/react-native/packager/packager.sh —nonPersistent” is run

pesterhazy12:10:35

yeah that's the same thing

pesterhazy12:10:47

npm start, reat-native start, packager.sh is all the same thing

pesterhazy12:10:29

the RN is packager is weird. Why can't you disable whole-program optimization?

levitanong12:10:33

aaaand this just happened:

<--- Last few GCs --->

  107608 ms: Mark-sweep 1360.1 (1435.2) -> 1360.1 (1435.2) MB, 2453.1 / 0.0 ms [allocation failure] [GC in old space requested].
  110077 ms: Mark-sweep 1360.1 (1435.2) -> 1360.1 (1435.2) MB, 2469.4 / 0.0 ms [allocation failure] [GC in old space requested].
  112562 ms: Mark-sweep 1360.1 (1435.2) -> 1363.6 (1419.2) MB, 2484.6 / 0.0 ms [last resort gc].
  115055 ms: Mark-sweep 1363.6 (1419.2) -> 1367.1 (1419.2) MB, 2492.4 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x76241dcfb51 <JS Object>
    1: visitQueue [/Users/levi/repos/load-app/node_modules/babel-traverse/lib/context.js:~114] [pc=0x1ff0c180cb82] (this=0x380393cc8451 <a TraversalContext with map 0x35352b580b11>,queue=0xda0eadf7869 <JS Array[1]>)
    2: node [/Users/levi/repos/load-app/node_modules/babel-traverse/lib/index.js:~94] [pc=0x1ff0c1837a82] (this=0x2532e6106309 <JS Function traverse (SharedFunctionInfo 0x3f68fc267ad…

pesterhazy12:10:09

yeah I've seen the issue with babel as well

pesterhazy12:10:20

maybe disable babel flow checks?

pesterhazy12:10:29

I always thought it may have something to do with that

levitanong12:10:49

ah, the type checker?

pesterhazy12:10:25

you get the impression that the JS world works (if it does) mostly be accident

levitanong12:10:55

😛 I went to clojurescript to escape the madness, but you can never really escape the madness

levitanong12:10:51

How would I disable it though? Would I have to dig in to node_modules and change something in there?

levitanong12:10:26

The only documentation on babel is {"plugins": ["syntax-flow"]} in .babelrc

pesterhazy12:10:37

I think there is a .babelrc or something you can add

pesterhazy12:10:46

oh you mentioned that 🙂

levitanong12:10:15

Oh, I’m supposed to add it

pesterhazy12:10:26

no I don't know really

pesterhazy12:10:53

so even react-native start runs out of memory for you?

levitanong12:10:54

Well yeah I wouldn’t even know how to indicate the absence of it in the .babelrc

levitanong12:10:18

npm start generally just stays there until i run react-native run-ios

levitanong12:10:42

If i’m in the re-natal dev mode, it runs fine

levitanong12:10:51

if i’m in the re-natal prod mode, it runs out of memory

levitanong12:10:14

I found it curious though, that react-native bundle ran out of memory before I even did run-ios

levitanong12:10:26

so maybe bundle is slightly different from npm start

pesterhazy12:10:35

so run-ios starts the app

pesterhazy12:10:49

the app makes a request to the web server at localhost something something

pesterhazy12:10:58

that triggers the packaging step

pesterhazy12:10:19

react-native bundle immediately packages the supplied entry point file

pesterhazy12:10:26

so no surprise that run-ios is not required

pesterhazy12:10:20

the main issue is that the RN packager doesn't expect the huge cljs-generated bundle we run it on

pesterhazy12:10:08

I never tried to use react-native start with a dev bundle

pesterhazy12:10:14

didn't know that re-natal did that

levitanong12:10:58

In re-natal, if you want to do dev (with figwheel) re-natal use-figwheel npm start react-native run-ios ;; different terminal lein figwheel ios if you want to run prod lein prod-build npm start react-native run-ios edit: moved npm start up

levitanong12:10:10

So i’m not sure if the re-natal use-figwheel thing is a dev bundle

pesterhazy12:10:01

@levitanong please report back if you find a solution

pesterhazy12:10:15

this is something that everyone who puts cljsrn in production will run into

levitanong12:10:15

@pesterhazy Haha, I will, though I think it’ll be unlikely that I’ll be the one to find the solution

pesterhazy12:10:43

I'm sure there's a hack waiting to happen

pesterhazy12:10:52

I've patched RN packager before

levitanong12:10:40

Anyway, thanks for the help, @pesterhazy! My problem may not be solved, but I learned a lot from you 😄

pesterhazy12:10:26

also create an issue on re-natal so people can track the progress

pesterhazy12:10:45

we're all in this together 🙂

levitanong12:10:51

Oh, right! will do