Closed sync-by-unito[bot] closed 3 years ago
➤ Alex Bevilacqua commented:
Opening this, which is a duplicate now for visibility (not sure if this is the right process).
Downgrading Electron hasn't helped, same crash. Seems like connected with 10.2.0 RealmJS
C:\Users\bartoszhernas>
ReleaseId: 9d096d9e8d1fcf156e90432e894a5a0f1db0a73a
12:54:59.541 > Is windows: true
12:54:59.552 > os.release(): 10.0.21286
12:54:59.556 > Is dev: false
Original user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) FreeYourMusic/6.0.0 Chrome/89.0.4389.69 Electron/12.0.0 Safari/537.36
Replaced user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) FreeYourMusic/6.0.0 Chrome/89.0.4389.69 Safari/537.36
12:54:59.657 > Web contents [object Object] created
rendererLocation: file://C:\Users\bartoszhernas\AppData\Local\Programs\freeyourmusic\resources\app.asar\build\index.html?userPath=C%3A%5CUsers%5Cbartoszhernas%5CAppData%5CRoaming%5CFreeYourMusic&deviceId=238033c100a4b6ddcc7cbea41a85bccb9fb91f80c302b01f7f296ec8e98e5cc2
Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, async open = false, client reset = false
Connection[1]: Connected to endpoint '52.16.113.157:443' (from '127.0.0.1:52895')
Connection[1]: Verifying server SSL certificate using 155 root certificates
12:55:02.486 > Checking for update
Received fatal exception 0xc06d007f
Backtrace:
PackageSidFromProductId [0x00007FF9E7C4D6A8+205438]
12:55:03.891 > Update for version 6.0.0 is not available (latest version: 6.0.0, downgrade is disallowed).
For what it's worth, Realm Studio is using Realm JS v10.1.3 with Electron v11.2.1.
I tried that versions and it's still failing.
It works only after disabling Sync, so seems like the issue is there.
I will now try to remove some parts of Sync code to see if I can make it work, it may be that clientResetError handling or something else is breaking that.
Tried downgrading Electron and RealmJS but it all constantly crashes when Sync is starting, no matter which versions combinations I've tried.
Realm Studio doesn't use Sync as far as I can tell, which would explain why it works.
Out findings:
All tested on Realm 10.2.0. We have tried both building on ARM64 M1 processor and X86 Intel processor (just in case something deep in the kernel was broken). It crashes no matter what machine is used to build it.
Basically, MongoDB Realm Sync crashes any Electron app >= 11. Latest Electron that works with Sync is 10.x
We have also tried terminating the Sync and enabling it again in case the issue was related to specific user, but this did not change anything. It crashed on freshly setup Sync. Trying oldest RealmJS that works with MongoDB crashes as well with Electron 11.x
This issue blocks usage of Realm Sync with Electron newer than 10.x.
Workaround for now that works for us:
Glad to see that I did not hallucinate this issue. If it can help debug the problem, for us Realm Sync started to work again after stopping Sync from the MongoDB dashboard and re-enabling it. If I remember correctly, this operation triggers a reset on all clients, so only use it while testing! In the end, we decided not to use Realm Sync so I cannot tell whether this solution was final.
➤ Ian Ward commented:
[~kenneth.geisshirt] [~brian.munkholm] Can the support czar look at this please? Does this need core help?
➤ Kenneth Geisshirt commented:
The non-Windows - or support for M1 Macs - can be fixed by upgrading to v10.4.1.
I have a simple Electron app on Windows 10 (64 bit, virtual machine)
|----|----|----| | |Realm JS 10.2.0|Realm JS 10.4.1| |Electron 10.4.6|Working|Not working| |Electron 12.0.8|Working|Not working|
I do observe "Received fatal exception 0xc06d007f" but a different error (the exception might not propagate in my app).
The comment yesterday didn't come out as nicely as it should. We have continued the investigation, and our small Electron app cannot load with Realm JS v10.3.0-rc.1, v10.3.0, 10.4.0 and 10.4.1 (tested both Electron v10.4.6 and Electron v12.0.8). The test app is able to load using 10.2.0 (both Electron v10.4.6 and Electron v12.0.8) and it is able to sync.
In v10.3.0-rc.1 we introduced a new build system, and we need to investigate why it produces a binary which doesn't work with Electron on Windows.
@bartoszhernas @marcoancona @bimusiek I understand you have observed the crash using Realm JS v10.2.0 but please verify that npm
hasn't upgraded to v10.3.0 or later by accident.
➤ Kræn Hansen commented:
Just reproduced a crash (still havn't extracted the backtrace) when initiating a sync connection using Realm JS 10.4.1 (and 10.2.0) and Electron 13.0.1 (and 12.0.9). The crash happens both in a main and renderer process. An interesting observation is that if the Realm was opened using Node.js first and Electron then reuses the database file on disk, the crash doesn't happen.
I managed to extract a core dump from the crash: [^bf6ea9eb-60da-439a-b9e1-ec7d98833705.dmp]
We'll have to continue the investigations by attaching a debugger and extracting more information.
I can verify that I'm experiencing the same crash with our library when built from our latest develop
branch.
Realm JavaScript v10.4.2 has a fix for Electon/Windows.
@kneth Please take a look at https://github.com/realm/realm-studio/issues/1430 We have the same issue using 10.4.2 and Electron 12 on Windows.
@kneth @kraenhansen I can see that realm-studio got the patch somehow. However, when I try to build the app with Realm 10.5.0 I am still getting the error
Uncaught Error: \\?\C:\Users\bimusiek\AppData\Local\Temp\3da4c319-5a47-4f25-9b04-8a36075b8f09.tmp.node is not a valid Win32 application.
Can we get this issue re-open please until the fix is provided?
@bimusiek thanks for pinging us here. I agree, we should reopen and fix this issue.
The temporary fix we needed in Realm Studio was this line:
touch node_modules/realm/binding.gyp
My investigations this far concludes: Electron Builder (the electron-builder
package on NPM) looks for (at least) the binding.gyp
file when determining if a dependency of an electron app has a native module or not. As a consequence Electron builder won't fetch the correct prebuilds when building the app for Windows nor Linux on a macOS machine. The binding.gyp
file was removed as we migrated Realm JS to cmake-js
.
We could add the empty file to our package, but since that feels a bit like a workaround, I would love to learn of alternative ways to tell electron-builder to consider Realm JS as having native modules which needs to be fetched when packaging up the app.
@kraenhansen Weird, I have added binding.gyp
as you suggested and it did not help. I mean, the build is much faster now, however it still does not work and produces the same error.
I am building with Apple M1, maybe that is the issue or maybe we are excluding too many dirs from the final package? I will investigate it more, but I am not so experienced with native packages for Electron though.
Ok, so I took a look at the asar
package and binding.gyp
is missing from there. My guess is that electron-builder fetches the pre-built package from github thus it is missing there? (In logs I can see install prebuilt binary
)
Another node package that was for react-native somehow got bundled into our asar and it was creating the same issue.
The fix from @kraenhansen works as expected.
touch node_modules/realm/binding.gyp
Thank you very much, we can finally update our windows app with newest Realm <3
I've created another issue with a more precise description: https://github.com/realm/realm-js/issues/3828 - please go watch that for updates.
@kraenhansen, Just wanted to know if the issue is resolved or not? If electron 11.x, 12.x works with realm sync in MacOs and windows?
@abhishekmatta999 Hey, we can confirm that Realm works great on both Windows, OSX (also native M1) and Linux. As long as you use workaround from https://github.com/realm/realm-studio/blob/channel/major-11/Jenkinsfile#L227-L228
You can check how it works on https://freeyourmusic.com if you wish. (It is Electron 15.1.1)
This was also being tracked in https://github.com/realm/realm-js/issues/3535, which was closed.
The latest version it works with is Electron 10.4.0. Any Electron 11.x, 12.x or even beta 13.x crashes the app.
We can see that Electron crashes the moment that Realm is initialized. If you need, we can provide you executable of exactly the same code built with Electron 10.4.0 (that works) and Electron 12.0.0 which crashes.
The workaround for us is to ship Electron 10.4.0 for Windows users and Electron 12.0.0 for the rest of the platforms (so we can support ARM64 on Apple).
Any suggestions how we can debug the issue would be much appreciated. The only info we have is
Backtrace: PackageSidFromProductId