react-native-threads icon indicating copy to clipboard operation
react-native-threads copied to clipboard

Thread bundle size optimisation

Open jacobp100 opened this issue 3 years ago • 11 comments

The readme should hopefully give a good description of what happens here

But for some real world numbers. My thread bundle was clocking in at 800kb. With this change, it dropped to 130kb. Considering the thread imports a 100kb pre-built (and already minified) file, I'd say this is a pretty great result!

jacobp100 avatar Nov 11 '20 17:11 jacobp100

@jacobp100 Thanks for this change, we're going to test this and pull into our fork

kamranpirwani avatar Oct 21 '21 13:10 kamranpirwani

@kamranpirwani I guess this PR moved in scope since it's just pointing at my master branch. It also brings stuff up-to-date with RN APIs (no more deprecated warnings), and improves performance and reliability too.

jacobp100 avatar Oct 21 '21 13:10 jacobp100

@jacobp100 Thanks for the update -- do you know offhand if you already added ability to async/await or I should add that? I saw there's more things in here so I was going to take and pluck things which potentially wouldn't be needed on our end

kamranpirwani avatar Oct 21 '21 13:10 kamranpirwani

@jacobp100 I'm seeing in general a 5-6 start time for 1st process to load (on our default fork) -- would be amazing if that can even go down by a factor of 2. Sometimes, spinning up the process might take longer than the operation itself -- but still operations we don't want to do on the JS side haha

kamranpirwani avatar Oct 21 '21 13:10 kamranpirwani

@kamranpirwani I think async/await is handled via babel, and Promises are polyfilled. If you use them, you gotta add import "react-native" as the first thing in your worker.

jacobp100 avatar Oct 21 '21 14:10 jacobp100

@jacobp100 Supposed to work out of the box? I'm seeing "[native] Sending message with no listeners registered." when queuing up a thread -- digging deeper into the changes now but wanted to see if working for you with latest set of commits

kamranpirwani avatar Oct 21 '21 22:10 kamranpirwani

"react-native": "0.64.2",

On Fri, Oct 22, 2021 at 1:39 PM Jacob Parker @.***> wrote:

@.**** commented on this pull request.

In ios/ThreadManager.m https://github.com/joltup/react-native-threads/pull/120#discussion_r734767070 :

  • [threads setObject:threadBridge forKey:[NSNumber numberWithInt:threadId]];
  • resolve([NSNumber numberWithInt:threadId]);

What version of react native?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joltup/react-native-threads/pull/120#discussion_r734767070, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANWTWFZIRENMWC47LHCYFLUIGVV5ANCNFSM4TSHUCSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Kamran Pirwani (415)-864-9166 @.***

kamranpirwani avatar Oct 22 '21 18:10 kamranpirwani

iOS or Android? I have a feeling I haven’t done the message deferring logic that happens on iOS for android yet. It refers sending messages until the bundle has loaded

jacobp100 avatar Oct 22 '21 21:10 jacobp100

I'll check Android shortly, this is happening on iOS in general, simulator and devices 100% of the time. I've basically dumbed down the implementation so a simple calculation to make sure it wasn't related to missing dependencies as well

On Fri, Oct 22, 2021 at 4:21 PM Jacob Parker @.***> wrote:

iOS or Android? I have a feeling I haven’t done the message deferring logic that happens on iOS for android yet. It refers sending messages until the bundle has loaded

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joltup/react-native-threads/pull/120#issuecomment-949966235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANWTWCI37KM4PZL4DCRYNLUIHIUBANCNFSM4TSHUCSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Kamran Pirwani (415)-864-9166 @.***

kamranpirwani avatar Oct 22 '21 21:10 kamranpirwani

Hmm. Make sure there’s no error in the worker. This library definitely works on iOS and I’m using it in production

jacobp100 avatar Oct 22 '21 21:10 jacobp100

@jacobp100 Thanks for all the responses/support. I tinkered with it a good bit, even an entirely empty thread with a simple response but still getting the same error. No worries, the idea here is great to reduce the number of things we don't need -- I'll apply a similar set of changes without the additional scope of changes here

kamranpirwani avatar Oct 23 '21 00:10 kamranpirwani