Skip to content

Commit 1852046

Browse files
committed
backend/usb: only force single thread on macOS
In a35e009 we forced all USB communication to happen in a single thread because macOS otherwise fails with obscure errors (see commit msg). For simplicity we applied this to all platforms. At least on Windows, users ar experiencing issues where the BitBox02 would timeout during password entry. It is not clear why, but since this was the only change related to USB communication, we revert it for all platforms except macOS.
1 parent 4e8bf8a commit 1852046

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 4.36.1
4+
- Fix USB communication issue on Windows
5+
36
## 4.36.0
47
- Re-style header for a better space utilisation
58
- Re-style sidebar navigation on mobile (portrait) to be full-screen for better space utilisation and a more modern look

backend/devices/usb/hid.go

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ import (
3030
var funcCalls chan func()
3131

3232
func init() {
33-
funcCalls = make(chan func())
34-
go func() {
35-
runtime.LockOSThread()
36-
for {
37-
f := <-funcCalls
38-
f()
39-
}
40-
}()
33+
if runtime.GOOS == "darwin" {
34+
funcCalls = make(chan func())
35+
go func() {
36+
runtime.LockOSThread()
37+
for {
38+
f := <-funcCalls
39+
f()
40+
}
41+
}()
42+
}
4143
}
4244

4345
type funcCallResult[T any] struct {
@@ -128,29 +130,37 @@ func (s singleThreadedDevice) Close() error {
128130

129131
// Open implements DeviceInfo.
130132
func (info hidDeviceInfo) Open() (io.ReadWriteCloser, error) {
131-
ch := make(chan funcCallResult[hid.Device])
132-
funcCalls <- func() {
133-
device, err := info.DeviceInfo.Open()
134-
ch <- funcCallResult[hid.Device]{device, err}
135-
}
136-
result := <-ch
137-
if result.err != nil {
138-
return nil, result.err
133+
if runtime.GOOS == "darwin" {
134+
ch := make(chan funcCallResult[hid.Device])
135+
funcCalls <- func() {
136+
device, err := info.DeviceInfo.Open()
137+
ch <- funcCallResult[hid.Device]{device, err}
138+
}
139+
result := <-ch
140+
if result.err != nil {
141+
return nil, result.err
142+
}
143+
return singleThreadedDevice{device: result.value}, nil
139144
}
140-
141-
return singleThreadedDevice{device: result.value}, nil
145+
return info.DeviceInfo.Open()
142146
}
143147

144148
// DeviceInfos returns a slice of all recognized devices.
145149
func DeviceInfos() []DeviceInfo {
146150
deviceInfosFiltered := []DeviceInfo{}
147151

152+
var result funcCallResult[[]hid.DeviceInfo]
148153
ch := make(chan funcCallResult[[]hid.DeviceInfo])
149-
funcCalls <- func() {
154+
if runtime.GOOS == "darwin" {
155+
funcCalls <- func() {
156+
di, err := hid.EnumerateHid(0, 0)
157+
ch <- funcCallResult[[]hid.DeviceInfo]{di, err}
158+
}
159+
result = <-ch
160+
} else {
150161
di, err := hid.EnumerateHid(0, 0)
151-
ch <- funcCallResult[[]hid.DeviceInfo]{di, err}
162+
result = funcCallResult[[]hid.DeviceInfo]{di, err}
152163
}
153-
result := <-ch
154164
// The library never actually returns an error in this functions.
155165
if result.err != nil {
156166
logging.Get().WithError(result.err).Error("EnumerateHid() returned an error")

backend/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const updateFileURL = "https://shiftcrypto.ch/updates/desktop.json"
2727

2828
var (
2929
// Version of the backend as displayed to the user.
30-
Version = semver.NewSemVer(4, 36, 0)
30+
Version = semver.NewSemVer(4, 36, 1)
3131
)
3232

3333
// UpdateFile is retrieved from the server.

frontends/qt/setup.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SetCompressor /SOLID lzma
2222

2323
# General Symbol Definitions
2424
!define REGKEY "SOFTWARE\$(^Name)"
25-
!define VERSION 4.36.0.0
25+
!define VERSION 4.36.1.0
2626
!define COMPANY "Shift Crypto AG"
2727
!define URL https://github.com/digitalbitbox/bitbox-wallet-app/releases/
2828
!define BINDIR "build\windows"

0 commit comments

Comments
 (0)