chrome-extensions-samples icon indicating copy to clipboard operation
chrome-extensions-samples copied to clipboard

Create a MV3 native host example

Open darbid opened this issue 3 years ago • 8 comments

With the arguably some of most controversial changes being made and they are now being pushed through in Jan 2021, why does not a single extension link work? Where is 1 V3 example? Most importantly where is a Native Host example with V3?

why not release some of your test extensions that you did for Native Host messaging and V3.

darbid avatar Feb 06 '21 13:02 darbid

Hi darbid. Thanks for asking. Did you look through the issues to see if this question had already been asked? A few of us have asked now and I've been waiting for clarity since @dotproto kindly offered to add them in December https://github.com/GoogleChrome/chrome-extensions-samples/issues/528 https://github.com/GoogleChrome/chrome-extensions-samples/issues/526 Not sure who is in charge here or how to get the ball rolling on this. Maybe you can do some digging for us and contact some people?

To be fair though, the mv3 docs overview gives a good explanation of what has changed and the major change is killing background workers in favour of service workers which is covered at https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/

I suspect Native Messaging is dead now or will be soon. I'm not surprised, from a security standpoint that sounds terrifying!

jfunction avatar Feb 06 '21 20:02 jfunction

Update: It seems like things are happening https://github.com/GoogleChrome/chrome-extensions-samples/pull/542

jfunction avatar Feb 06 '21 20:02 jfunction

Thank you. Looks like vrong read my issue and has also noted it yesterday in 542. So all good there.

I otherwise am sorry to say I do not share your opinion. I am not sure MV3 is clearly explained. For example do they make it clear how, when and in what circumstances Chrome will kill your service worker? The material promises promises :-) but where are they indicated in the material or examples?

Do you have any links on your suspicion? I was unaware that removing Native Messaging formed any part of the roadmap for V3.

darbid avatar Feb 07 '21 06:02 darbid

Looks like I misread the warning on https://developer.chrome.com/docs/apps/nativeMessaging/ which talks about Chrome Apps being dead soon. I guess the examples link (pointing to mv2 archived extensions) at https://developer.chrome.com/docs/extensions/mv3/messaging/#examples will be updated soon and we'll see a sample with MV3 + Native Messaging.

Have you tried https://github.com/GoogleChrome/chrome-extensions-samples/tree/master/mv2-archive/api/nativeMessaging but just bumping the version to 3 in the manifest? It seems pretty bare bones and doesn't seem to use a background worker so that might work?

jfunction avatar Feb 07 '21 09:02 jfunction

From a newbie perspective. It's quite difficult to start learning about Chrome Extensions while every resource on the internet (besides the docs) is talking about MV2, which is understandable: MV3 was just introduced in early Jan.

But yes, I was hoping to find a MV3 example in the Google Chrome Extensions Samples official repo to wrap my head around.

If there's any MV3 example already, please, point it to me. Thanks!

piscespieces avatar Feb 20 '21 20:02 piscespieces

A bit off topic but I agree - it's frustrating not getting any answers on these queries but I assume there's a good reason for it.

That said it's uplifting to see that work is being done on this stuff in the background. For example there is now a basic MV3 extension walkthrough. I tested it on my machine recently and it works :)

https://developer.chrome.com/docs/extensions/mv3/getstarted/ Link to the code is on that page also, but I recommend going step by step. The various MV3 pieces of documentation are also quite informative actually and I managed to extract plenty of good info from them. Good luck.

jfunction avatar Feb 20 '21 21:02 jfunction

If there's any MV3 example already, please, point it to me. Thanks!

See https://bugs.chromium.org/p/chromium/issues/detail?id=1189678#c40, https://github.com/guest271314/NativeTransferableStreams/tree/main/native_messaging_local_server.

guest271314 avatar May 30 '21 03:05 guest271314

For example do they make it clear how, when and in what circumstances Chrome will kill your service worker?

No.

Workarounds https://bugs.chromium.org/p/chromium/issues/detail?id=1152255#c25, https://bugs.chromium.org/p/chromium/issues/detail?id=1152255#c32.

Aside from ServiceWorker becoming inactive in 5 minutes MV3 Native Messaging host should function the same as MV2.

See https://github.com/simov/native-messaging for an example host using Node.js.

guest271314 avatar Jul 06 '21 02:07 guest271314

We just merged an MV3 sample here: https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/api-samples/nativeMessaging

Thanks for your patience everyone.

oliverdunk avatar Feb 02 '24 13:02 oliverdunk